//Commons.js
//

function showpopup(url, title, w, h) {
	window.open(url, title, "location=0,status=1,resizable=1,scrollbars=1,width=" + w + ",height=" + h + "");
	return false;
}


function postCodeValidate(source, arguments) {
	arguments.IsValid = true;
	
	var countryText = (ddlCountry.options[ddlCountry.options.selectedIndex].text);
	if (countryText == "UK" || countryText == "U.K." || countryText == "U.K." || countryText == "United Kingdom" || countryText == "England" || countryText == "Great Britain"  || countryText == "Greate Briton" || countryText == "GB") {
		arguments.IsValid = false;
		if (checkPostCode(txtZip.value)) {
			arguments.IsValid = true;
		}
	}
	
}

function postCodeValidate_dir(source, arguments) {
	var countryText = "";
	try {
		countryText = (ddlCountry.options[ddlCountry.options.selectedIndex].text);
	} catch (error) {
		countryText = (txtZip.value);
	}
	
	if (countryText === "" || countryText === undefined || countryText === null) {
		arguments.IsValid = false;
	}
	
	if (countryText == "UK" | countryText == "U.K." || countryText == "U. K." || countryText == "United Kingdom" || countryText == "England" || countryText == "Great Britain" || countryText == "Greate Briton" || countryText == "GB") {

		if (checkPostCode(txtZip.value)) {

			arguments.IsValid = true;
		}
		else {

			arguments.IsValid = false;
		}
	}
	else {

		arguments.IsValid = true;
	}

	return true;
}


function checkPostCode(toCheck) {

	// Permitted letters depend upon their position in the postcode.
	var alpha1 = "[abcdefghijklmnoprstuwyz]";                       // Character 1
	var alpha2 = "[abcdefghklmnopqrstuvwxy]";                       // Character 2
	var alpha3 = "[abcdefghjkstuw]";                                // Character 3
	var alpha4 = "[abehmnprvwxy]";                                  // Character 4
	var alpha5 = "[abdefghjlnpqrstuwxyz]";                          // Character 5

	// Array holds the regular expressions for the valid postcodes
	var pcexp = new Array();

	// Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
	pcexp.push(new RegExp("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));

	// Expression for postcodes: ANA NAA
	pcexp.push(new RegExp("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));

	// Expression for postcodes: AANA  NAA
	pcexp.push(new RegExp("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$", "i"));

	// Exception for the special postcode GIR 0AA
	pcexp.push(/^(GIR)(\s*)(0AA)$/i);

	// Standard BFPO numbers
	pcexp.push(/^(bfpo)(\s*)([0-9]{1,4})$/i);

	// c/o BFPO numbers
	pcexp.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);

	// Overseas Territories
	pcexp.push(/^([A-Z]{4})(\s*)(1ZZ)$/i);

	// Load up the string to check
	var postCode = toCheck;

	// Assume we're not going to find a valid postcode
	var valid = false;

	// Check the string against the types of post codes
	for (var i = 0; i < pcexp.length; i++) {
		if (pcexp[i].test(postCode)) {

			// The post code is valid - split the post code into component parts
			pcexp[i].exec(postCode);

			// Copy it back into the original string, converting it to uppercase and
			// inserting a space between the inward and outward codes
			postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();

			// If it is a BFPO c/o type postcode, tidy up the "c/o" part
			postCode = postCode.replace(/C\/O\s*/, "c/o ");

			// Load new postcode back into the form element
			valid = true;

			// Remember that we have found that the code is valid and break from loop
			break;
		}
	}

	// Return with either the reformatted valid postcode or the original invalid 
	// postcode
	if (valid) 
	{ return postCode; } 
	else {
	return false; }
}


function validateForm() {
	if (checkValidation()) {
		if (validateTerms()) {

			return true;
		}
		else {

			return false;
		}
	} else {
		return false;
	}

	return true;
}


function isProper(val, control) {
	var result = true;
	var string = val;
	var iChars = "*|,\":<>[]{}`\';()&$#%";
	for (var i = 0; i < string.length; i++) {
		if (iChars.indexOf(string.charAt(i)) != "-1") {
			$("#lblPwdError").html('Please enter a proper value for the "' + control + '" field.');
			return false;            
		}
	}
	return true;
}




function validatePassword() {
	var pwd = $("#ctl00_ContentMainPane_txtPassword").val();
	var pwdC = $("#ctl00_ContentMainPane_txtConfirmPassword").val();
	if (trimAll(pwd) === "" || trimAll(pwd) === null || trimAll(pwd) === undefined) {

	   $("#lblPwdError").html("Password cannot be left blank");

		return false;
	}

	if (trimAll(pwdC) === ""|| trimAll(pwdC) === null || trimAll(pwdC) === undefined) {
		 $("#lblPwdError").html("Confirm Password cannot be left blank");
		return false;
	}

	if (pwd != pwdC) {
		 $("#lblPwdError").html( "Password should match to Confirm password");
		return false;
	}

	if (pwd.length < 8) {
		 $("#lblPwdError").html("Password must be Secure, click on ? icon for help");
		return false;
	}

	$("#lblPwdError").html('');
	return true;
}


function validateUser(uname, uID, folder) {
	if (uname !== "" && uname !== undefined && uname !== null) {
		var oXmlHttp = null;
		var str = '/handlers/';
		if (!sendRequest(oXmlHttp, str + "GenericHandler.ashx?fid=1&value=" + uname + "&usrID=" + uID, "userExists")) {
				$("#userExists").html("There is Error while loading Validtor");
		}
	} else {
		 $("#userExists").html("");
	}
}



function trimAll(sString) {
	while (sString.substring(0, 1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length - 1, sString.length) == ' ') {
		sString = sString.substring(0, sString.length - 1);
	}
	return sString;
}



function ifrSource(ifrid, url) {

	$('#'+ifrid).attr('src',url);
}

// For Voucher Add/edit

function SearchSupplier(SupplierName) {
	if (SupplierName !== "" && SupplierName !== undefined && SupplierName !== null) {
		var oXmlHttp = null;
		if (!sendRequestSupplier(oXmlHttp, "/handlers/SupplierSearchHandler.ashx?SupplierName=" + SupplierName, "supplierDiv")) {
			$("#supplierDiv").html( "No County Found");
		}
	} else {
			$("#supplierDiv").html("");
	}
}


/// For Pramotional Email




function toggleDisplay(control) {
	if ($('#'+control).css('display') !== "none") {
		$('#'+control).css('display','none');
	}
	else {
		$('#'+ control).css('display','block');
	}
}

var ios = 0;
var aos = 0;
function insertOldSchool(theSel, newText, newValue) {
	var newOpt1 = new Option(newText, newValue);
	theSel.options[theSel.length] = newOpt1;
	theSel.selectedIndex = 0;
}


function getDirCounty(cntryid) {
	var Oxml;
	var responsestring = "";
   
		Oxml = createXMLHttp();
		if (Oxml === null || Oxml === undefined) {
			return;
		}
		Oxml.open('get', "/handlers/CountyHandler.ashx?CountryID=" + cntryid);
		Oxml.onreadystatechange = function() {
			if (Oxml.readyState === 4) {
				responsestring = Oxml.responseText;
				// EMPTY THE EXISTING COUNTIES
				var theSel = cntyobj;
				for (i = cntyobj.length - 1; i >= 0; i--) {
					theSel.options[i] = null;
				}

				// PARSING THE COUNTY STRING               
					var arr = responsestring.split(",");
					if ((arr.length - 1) > 0) {
						cntyRow.style.display = 'block';
						for (i = 0; i < arr.length - 1; i++) {
							var arr_sub = arr[i].split("|");
							insertOldSchool(theSel, arr_sub[1], arr_sub[0]);
						}
					}
					else {
						cntyRow.style.display = 'none';

					}
				
			}
		};
		Oxml.send(null);
   
}


function getDirCountryCounty(dirlistid) {

	var Oxml;
	var responsestring = "";
	
		Oxml = createXMLHttp();
		if (Oxml === null || Oxml === undefined) {
			return ;
		}

		Oxml.open('get', "/handlers/GetCountryCountry.ashx?dirListId=" + dirlistid);

		Oxml.onreadystatechange = function() {
			if (Oxml.readyState === 4) {

				responsestring = Oxml.responseText + " Average";


				// EMPTY THE EXISTING COUNTIES
			   $("#ctl00_ContentMainPane_regionLabel").html(responsestring);


				// PARSING THE COUNTY STRING


			}
		};
		Oxml.send(null);

	
}


function pcase(str) {

	strlen = str.length;
	jj = str.substring(0, 1).toUpperCase();
	jj = jj + str.substring(1, strlen).toLowerCase();
	for (i = 2; i <= strlen; i++) {
		if (jj.charAt(i) == " ") {
			lefthalf = jj.substring(0, i + 1);
			righthalf = jj.substring(i + 1, strlen);
			righthalf = righthalf.substring(0, 1).toUpperCase() + righthalf.substring(1, strlen);
			jj = lefthalf + righthalf;
		}
	}
	return jj;
}
function isProperHTML1(val, control) {
	var result = true;
	var string = val;
	var iChars = "<[^>]*>";
	for (var i = 0; i < string.length; i++) {
		if (iChars.indexOf(string.charAt(i)) != "-1") {
			$('#'+control).html('Invalid text format');
			return false;           
		}
		else {
			$('#'+control).html("");
		}
	}
	return true;
}
//End Commons.js
// JScript File

// JavaScript Document
function createXMLHttp()
{
	if( typeof XMLHttpRequest != "undefined")
	{
	return new XMLHttpRequest();	
	}
	else if(window.ActiveXObject)
	{
		var aVersion = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"]
		for(var i=0; i<aVersion.length; i++)
		{
			try{
				var oXmlHttp = new ActiveXObject(aVersion[i]);
				return oXmlHttp;
			}
			catch (oError)
			{
				
			}
		}
	}
	throw new Error("XMLHttp Object Cannot be found");
}

function sendRequest(Oxml,URL,IContent)
{
	try
	{
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		return false;
		}
		saveData(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}

}

function saveData(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			document.getElementById(id).innerHTML = response;
			}
			else
			{
			document.getElementById(id).innerHTML = "Server encountered an error, please try again.";
			}
			
		}
	};
	Oxml.send(null);
}

function sendRequestCounty(Oxml,URL,IContent)
{
	try
	{
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		return false;
		}
		saveDataCounty(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}

}

function saveDataCounty(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			    var myArray = response
			    var val = myArray.split(",");
			    document.getElementById("ctl00_ContentMainPane_ddlcounty").options.length = 0;
			    for(var i = 0; i < val.length; i++)
			    {
			        addOptions(document.getElementById("ctl00_ContentMainPane_ddlcounty"), val[i]);    
		        }
			}
			else
			{document.getElementById(id).innerHTML = "Server encountered an error, please try again.";}
		}
	};
	Oxml.send(null);
}

function addOptions(selectbox,value)
{
    var INDEX = value.indexOf('|');
//    alert("INDEX=>" + INDEX);
//    alert("value=>" + value.substring(0,INDEX));
//    alert("Text=>" + value.substring(INDEX + 1 ,value.length));
    
        var text=value.substring(INDEX + 1 ,value.length)
        var values=value.substring(0,INDEX)
        var optn = document.createElement("OPTION");
    
    if ( INDEX != -1 )
    {    
        optn.text = text;
        optn.value = values;
        selectbox.options.add(optn);
    }
    else
    {
        optn.text = "All County";
        optn.value = INDEX;
        selectbox.options.add(optn);
    }
    
}



////////////////////For Supplier SEarch

function sendRequestSupplier(Oxml,URL,IContent)
{
    
	try
	{
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		return false;
		}
		saveDataSupplier(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}
}

function saveDataSupplier(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			    
			    var myArray = response
			    
			    var val = myArray.split(",");
			    document.getElementById("ctl00_ContentMainPane_ListBox1").options.length = 0;
			    for(var i = 0; i < val.length; i++)
			    {
			        var EIndex = val[i].indexOf(':');
			        var CompID = val[i].substring(0,EIndex);
			        val[i] = val[i].replace(CompID + ':', '')
			        var optn = document.createElement("OPTION");
			        if ( EIndex != -1 )
                    {    
                        optn.text = val[i];
                        optn.value = CompID;
                        document.getElementById("ctl00_ContentMainPane_ListBox1").options.add(optn);
                    }
                    else
                    {
//                        optn.text = "All Suppliers";
//                        optn.value = EIndex;
//                        document.getElementById("ctl00_ContentMainPane_ListBox1").options.add(optn);
                    }
		        }
			}
			else
			{document.getElementById(id).innerHTML = "Server encountered an error, please try again.";}
		}
	};
	Oxml.send(null);
}

//function For Pramotional Email

////////////////////For Supplier SEarch

function sendRequestSupplierEmail(Oxml,URL,IContent)
{
	try
	{   
	    
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		return false;
		}
		saveDataSupplierEmail(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}

}

function saveDataSupplierEmail(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			    
			    var myArray = response
			    var val = myArray.split(",");
			    document.getElementById("ctl00_ContentMainPane_ListBox1").options.length = 0;
			    for(var i = 0; i < val.length; i++)
			    {
			        var EIndex = val[i].indexOf(':');
			        var Email = val[i].substring(0,EIndex);
			        val[i] = val[i].replace(Email + ':', '')
			        var INDEX = val[i].indexOf('|');
			        var values=val[i].substring(0,INDEX)
			        var optn = document.createElement("OPTION");
//			        alert("EIndex Are :->" + EIndex )
//			        alert("Values Are :->" + val[i] )
			        if ( EIndex != -1 )
                    {    
                        optn.text = val[i];
                        optn.value = Email;
                        document.getElementById("ctl00_ContentMainPane_ListBox1").options.add(optn);
                    }
                    else
                    {
//                        optn.text = "All County";
//                        optn.value = INDEX;
//                        document.getElementById("ctl00_ContentMainPane_ListBox1").options.add(optn);
                    }
		        }
			}
			else
			{document.getElementById(id).innerHTML = "Server encountered an error, please try again.";}
		}
	};
	Oxml.send(null);
}

// For Listing Type

function sendRequestListing(Oxml,URL,IContent)
{
	try
	{
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		return false;
		}
		saveDataListing(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}

}

function saveDataListing(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			    var myArray = response
			    var val = myArray.split(",");
			    //document.getElementById("ctl00_ContentMainPane_ddlDirectoryListing").options.length = 0;
			    var firstVal = val[0].indexOf(':');
		        firstVal = val[0].substring(0,firstVal);
		        document.getElementById('ctl00_ContentMainPane_hidDirectoryListing').value=firstVal;
                    
			    for(var i = 0; i < val.length; i++)
			    {
			            
			        var EIndex = val[i].indexOf(':');
			        var Email = val[i].substring(0,EIndex);
			        val[i] = val[i].replace(Email + ':', '')
			        var INDEX = val[i].indexOf('|');
			        var values=val[i].substring(0,INDEX)
			        var optn = document.createElement("OPTION");
//			        alert("EIndex Are :->" + EIndex )
//			        alert("Values Are :->" + val[i] )
			        if ( EIndex != -1 )
                    {    
//                        optn.text = val[i];
//                        optn.value = Email;
//                        document.getElementById("ctl00_ContentMainPane_ddlDirectoryListing").options.add(optn);
                    }
                    else
                    {
//                        optn.text = "All Listing";
//                        optn.value = "0";
//                        document.getElementById("ctl00_ContentMainPane_ddlDirectoryListing").options.add(optn);
                    }
		        }
		        
			}
			else
			{document.getElementById(id).innerHTML = "Server encountered an error, please try again.";}
		}
	};
	Oxml.send(null);
}

//For Reivew Supplier



function sendRequestReview(Oxml,URL,IContent)
{
	try
	{
		Oxml=createXMLHttp();
		if(Oxml == null)
		{
		    if (this.console && typeof console.log != "undefined")
		        console.log("ERROR IN GENERATING OBJECT");
		    return false;
		}
		saveDataReview(URL,IContent,Oxml);			
		return true;		
	}
	catch (oError)
	{
	return false;	
	}

}

function saveDataReview(action,id,Oxml) {
	Oxml.open('get', action);
	Oxml.onreadystatechange = function(){

		if(Oxml.readyState == 4)
		{
			var response = Oxml.responseText;
			if (response.search(/Thread was being aborted/i)==-1)
			{
			    var myArray = response
			    
			    //COMPID-LISTID:BirkShaire/London/Primium
			    var val = myArray.split(",");
			    document.getElementById("ctl00_ContentMainPane_ListBox1").options.length = 0;
			    for(var i = 0; i < val.length; i++)
			    {
			        //alert(val[i])
			        var EIndex = val[i].indexOf(':');
			        var ListName = val[i].substring(0,EIndex);
			        val[i] = val[i].replace(ListName + ':', '')
			        var optn = document.createElement("OPTION");
			        if ( EIndex != -1 )
                    {    
                        optn.text = val[i];
                        optn.value = ListName;
                        document.getElementById("ctl00_ContentMainPane_ListBox1").options.add(optn);
                    }
                    else
                    {
                    }
		        }
		        
			}
			else
			{document.getElementById(id).innerHTML = "Server encountered an error, please try again.";}
		}
	};
	Oxml.send(null);
}/************************************************************************************************************
Ajax dynamic content
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com
	
************************************************************************************************************/	



var enableCache = true;
var jsCache = new Array();

var dynamicContent_ajaxObjects = new Array();

function ajax_showContent(divId,ajaxIndex,url)
{
	document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = 	dynamicContent_ajaxObjects[ajaxIndex].response;
	}
	dynamicContent_ajaxObjects[ajaxIndex] = false;
}

function ajax_loadContent(divId,url)
{
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}

	
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	document.getElementById(divId).innerHTML = '<table cellpadding="2" cellspacing="1" bgcolor="#000000"><tr bgcolor="#FFFFC5"><td style="vertical-align:middle;font-family:arial;font-size:12px;color:#000000;cursor:help;">Loading ...</td></tr></table>';
	
	//document.getElementById(divId).innerHTML = '<div style="vertical-align:middle;font-family:arial;font-size:12px;color:#000000;cursor:help;">Loading content - please wait'</div>;
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	
	if(url.indexOf('?')>=0){
		dynamicContent_ajaxObjects[ajaxIndex].method='GET';
		var string = url.substring(url.indexOf('?'));
		url = url.replace(string,'');
		string = string.replace('?','');
		var items = string.split(/&/g);
		for(var no=0;no<items.length;no++){
			var tokens = items[no].split('=');
			if(tokens.length==2){
				dynamicContent_ajaxObjects[ajaxIndex].setVar(tokens[0],tokens[1]);
			}	
		}	
		url = url.replace(string,'');
	}
	
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Specify function that will be executed after file has been found
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	
	
	
}
/* Simple AJAX Code-Kit (SACK) */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */

function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {
				this.xmlhttp = null;
			}
		}
		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
			this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp){
			this.failed = true; 
		}
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
	return varArray.join('&');
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){
		    if (this.console && typeof console.log != "undefined")
		        console.log(this.AjaxFailedAlert); 
		} else {
			if (urlstring){ 
				if (this.URLString.length){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}

				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}


/************************************************************************************************************
Ajax tooltip
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com
	
************************************************************************************************************/	




/* Custom variables */

/* Offset position of tooltip */
var x_offset_tooltip = 5;
var y_offset_tooltip = 0;

/* Don't change anything below here */


var ajax_tooltipObj = false;
var ajax_tooltipObj_iframe = false;

var ajax_tooltip_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;


function ajax_showTooltip(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.id = 'ajax_tooltipObj';		
		document.body.appendChild(ajax_tooltipObj);
		
		var leftDiv = document.createElement('DIV');	/* Create arrow div */
		leftDiv.className='ajax_tooltip_arrow';
		leftDiv.id = 'ajax_tooltip_arrow';
		ajax_tooltipObj.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV'); /* Create tooltip content div */
		contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE)
	{
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}
	
	ajax_positionTooltip(inputObj,ajax_tooltipObj);
}

function ajax_positionTooltip(inputObj, ajax_tooltipObj)
{
    var leftPos
    var lefPos = eval(ajaxTooltip_getLeftPos(inputObj));
    var diff  = eval(document.body.offsetWidth) - (lefPos);
    if(diff < 110)
	  {
	  leftPos = ajax_tooltipObj.offsetWidth;
	  ajax_tooltipObj.style.right = leftPos + 'px';
	 }
	else
	{
	  leftPos = (lefPos + inputObj.offsetWidth);
	  ajax_tooltipObj.style.left = leftPos + 'px';
	}
	var topPos = ajaxTooltip_getTopPos(inputObj);
	ajax_tooltipObj.style.top = topPos + 'px';	
}
function ajax_hideTooltip()
{
	ajax_tooltipObj.style.display='none';
}

function ajaxTooltip_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
 
}/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/

; (function ($) {
    var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,

		selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],

		ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,

		loadingTimer, loadingFrame = 1,

		titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),

		isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

    /*
    * Private methods 
    */

		_abort = function () {
		    loading.hide();

		    imgPreloader.onerror = imgPreloader.onload = null;

		    if (ajaxLoader) {
		        ajaxLoader.abort();
        } 

		    tmp.empty();
		},

		_error = function () {
		    if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
		        loading.hide();
		        busy = false;
		        return;
		    }

		    selectedOpts.titleShow = false;

		    selectedOpts.width = 'auto';
		    selectedOpts.height = 'auto';

		    tmp.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');

		    _process_inline();
		},

		_start = function () {
		    var obj = selectedArray[selectedIndex],
				href,
				type,
				title,
				str,
				emb,
				ret;

		    _abort();

		    selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

		    ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

		    if (ret === false) {
		        busy = false;
		        return;
		    } else if (typeof ret == 'object') {
		        selectedOpts = $.extend(selectedOpts, ret);
		    }

		    title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

		    if (obj.nodeName && !selectedOpts.orig) {
		        selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
		    }

		    if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
		        title = selectedOpts.orig.attr('alt');
		    }

		    href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

		    if ((/^(?:javascript)/i).test(href) || href == '#') {
		        href = null;
		    }

		    if (selectedOpts.type) {
		        type = selectedOpts.type;

		        if (!href) {
		            href = selectedOpts.content;
		        }

		    } else if (selectedOpts.content) {
		        type = 'html';

		    } else if (href) {
		        if (href.match(imgRegExp)) {
		            type = 'image';

		        } else if (href.match(swfRegExp)) {
		            type = 'swf';

		        } else if ($(obj).hasClass("iframe")) {
		            type = 'iframe';

		        } else if (href.indexOf("#") === 0) {
		            type = 'inline';

        } else {
		            type = 'ajax';
        } 
        } 

		    if (!type) {
		        _error();
		        return;
            } 

		    if (type == 'inline') {
		        obj = href.substr(href.indexOf("#"));
		        type = $(obj).length > 0 ? 'inline' : 'ajax';
        } 

		    selectedOpts.type = type;
		    selectedOpts.href = href;
		    selectedOpts.title = title;

		    if (selectedOpts.autoDimensions) {
		        if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
		            selectedOpts.width = 'auto';
		            selectedOpts.height = 'auto';
		        } else {
		            selectedOpts.autoDimensions = false;
        } 
    }

		    if (selectedOpts.modal) {
		        selectedOpts.overlayShow = true;
		        selectedOpts.hideOnOverlayClick = false;
		        selectedOpts.hideOnContentClick = false;
		        selectedOpts.enableEscapeButton = false;
		        selectedOpts.showCloseButton = false;
            } 

		    selectedOpts.padding = parseInt(selectedOpts.padding, 10);
		    selectedOpts.margin = parseInt(selectedOpts.margin, 10);

		    tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

		    $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function () {
		        $(this).replaceWith(content.children());
		    });

		    switch (type) {
		        case 'html':
		            tmp.html(selectedOpts.content);
		            _process_inline();
		            break;

		        case 'inline':
		            if ($(obj).parent().is('#fancybox-content') === true) {
		                busy = false;
		                return;
		            }

		            $('<div class="fancybox-inline-tmp" />')
						.hide()
						.insertBefore($(obj))
						.bind('fancybox-cleanup', function () {
						    $(this).replaceWith(content.children());
						}).bind('fancybox-cancel', function () {
						    $(this).replaceWith(tmp.children());
						});

		            $(obj).appendTo(tmp);

		            _process_inline();
		            break;

		        case 'image':
		            busy = false;

		            $.fancybox.showActivity();

		            imgPreloader = new Image();

		            imgPreloader.onerror = function () {
		                _error();
		            };

		            imgPreloader.onload = function () {
		                busy = true;

		                imgPreloader.onerror = imgPreloader.onload = null;

		                _process_image();
		            };

		            imgPreloader.src = href;
		            break;

		        case 'swf':
		            selectedOpts.scrolling = 'no';

		            str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
		            emb = '';

		            $.each(selectedOpts.swf, function (name, val) {
		                str += '<param name="' + name + '" value="' + val + '"></param>';
		                emb += ' ' + name + '="' + val + '"';
		            });

		            str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

		            tmp.html(str);

		            _process_inline();
		            break;

		        case 'ajax':
		            busy = false;

		            $.fancybox.showActivity();

		            selectedOpts.ajax.win = selectedOpts.ajax.success;

		            ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
		                url: href,
		                data: selectedOpts.ajax.data || {},
		                error: function (XMLHttpRequest, textStatus, errorThrown) {
		                    if (XMLHttpRequest.status > 0) {
		                        _error();
		                    }
		                },
		                success: function (data, textStatus, XMLHttpRequest) {
		                    var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
		                    if (o.status == 200) {
		                        if (typeof selectedOpts.ajax.win == 'function') {
		                            ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

		                            if (ret === false) {
		                                loading.hide();
		                                return;
		                            } else if (typeof ret == 'string' || typeof ret == 'object') {
		                                data = ret;
		                            }
		                        }

		                        tmp.html(data);
		                        _process_inline();
		                    }
		                }
		            }));

		            break;

		        case 'iframe':
		            _show();
		            break;
		    }
		},

		_process_inline = function () {
		    var 
				w = selectedOpts.width,
				h = selectedOpts.height;

		    if (w.toString().indexOf('%') > -1) {
		        w = parseInt(($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';

		    } else {
		        w = w == 'auto' ? 'auto' : w + 'px';
		    }

		    if (h.toString().indexOf('%') > -1) {
		        h = parseInt(($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';

		    } else {
		        h = h == 'auto' ? 'auto' : h + 'px';
		    }

		    tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');

		    selectedOpts.width = tmp.width();
		    selectedOpts.height = tmp.height();

		    _show();
		},

		_process_image = function () {
		    selectedOpts.width = imgPreloader.width;
		    selectedOpts.height = imgPreloader.height;

		    $("<img />").attr({
		        'id': 'fancybox-img',
		        'src': imgPreloader.src,
		        'alt': selectedOpts.title
		    }).appendTo(tmp);

		    _show();
		},

		_show = function () {
		    var pos, equal;

		    loading.hide();

		    if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
		        $.event.trigger('fancybox-cancel');

		        busy = false;
		        return;
		    }

		    busy = true;

		    $(content.add(overlay)).unbind();

		    $(window).unbind("resize.fb scroll.fb");
		    $(document).unbind('keydown.fb');

		    if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
		        wrap.css('height', wrap.height());
		    }

		    currentArray = selectedArray;
		    currentIndex = selectedIndex;
		    currentOpts = selectedOpts;

		    if (currentOpts.overlayShow) {
		        overlay.css({
		            'background-color': currentOpts.overlayColor,
		            'opacity': currentOpts.overlayOpacity,
		            'cursor': currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
		            'height': $(document).height()
		        });

		        if (!overlay.is(':visible')) {
		            if (isIE6) {
		                $('select:not(#fancybox-tmp select)').filter(function () {
		                    return this.style.visibility !== 'hidden';
		                }).css({ 'visibility': 'hidden' }).one('fancybox-cleanup', function () {
		                    this.style.visibility = 'inherit';
		                });
		            }

		            overlay.show();
		        }
		    } else {
		        overlay.hide();
		    }

		    final_pos = _get_zoom_to();

		    _process_title();

		    if (wrap.is(":visible")) {
		        $(close.add(nav_left).add(nav_right)).hide();

		        pos = wrap.position(),

				start_pos = {
				    top: pos.top,
				    left: pos.left,
				    width: wrap.width(),
				    height: wrap.height()
				};

		        equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);

		        content.fadeTo(currentOpts.changeFade, 0.3, function () {
		            var finish_resizing = function () {
		                content.html(tmp.contents()).fadeTo(currentOpts.changeFade, 1, _finish);
		            };

		            $.event.trigger('fancybox-change');

		            content
						.empty()
						.removeAttr('filter')
						.css({
						    'border-width': currentOpts.padding,
						    'width': final_pos.width - currentOpts.padding * 2,
						    'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
						});

		            if (equal) {
		                finish_resizing();

		            } else {
		                fx.prop = 0;

		                $(fx).animate({ prop: 1 }, {
		                    duration: currentOpts.changeSpeed,
		                    easing: currentOpts.easingChange,
		                    step: _draw,
		                    complete: finish_resizing
		                });
		            }
		        });

		        return;
		    }

		    wrap.removeAttr("style");

		    content.css('border-width', currentOpts.padding);

		    if (currentOpts.transitionIn == 'elastic') {
		        start_pos = _get_zoom_from();

		        content.html(tmp.contents());

		        wrap.show();

		        if (currentOpts.opacity) {
		            final_pos.opacity = 0;
		        }

		        fx.prop = 0;

		        $(fx).animate({ prop: 1 }, {
		            duration: currentOpts.speedIn,
		            easing: currentOpts.easingIn,
		            step: _draw,
		            complete: _finish
		        });

		        return;
		    }

		    if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
		        title.show();
		    }

		    content
				.css({
				    'width': final_pos.width - currentOpts.padding * 2,
				    'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
        })
				.html(tmp.contents());

		    wrap
				.css(final_pos)
				.fadeIn(currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish);
		},

		_format_title = function (title) {
		    if (title && title.length) {
		        if (currentOpts.titlePosition == 'float') {
		            return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
            } 

		        return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
        } 

		    return false;
		},

		_process_title = function () {
		    titleStr = currentOpts.title || '';
		    titleHeight = 0;

		    title
				.empty()
				.removeAttr('style')
				.removeClass();

		    if (currentOpts.titleShow === false) {
		        title.hide();
		        return;
		    }

		    titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);

		    if (!titleStr || titleStr === '') {
		        title.hide();
		        return;
		    }

		    title
				.addClass('fancybox-title-' + currentOpts.titlePosition)
				.html(titleStr)
				.appendTo('body')
				.show();

		    switch (currentOpts.titlePosition) {
		        case 'inside':
		            title
						.css({
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'marginLeft': currentOpts.padding,
						    'marginRight': currentOpts.padding
						});

		            titleHeight = title.outerHeight(true);

		            title.appendTo(outer);

		            final_pos.height += titleHeight;
		            break;

		        case 'over':
		            title
						.css({
						    'marginLeft': currentOpts.padding,
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'bottom': currentOpts.padding
						})
						.appendTo(outer);
		            break;

		        case 'float':
		            title
						.css('left', parseInt((title.width() - final_pos.width - 40) / 2, 10) * -1)
						.appendTo(wrap);
		            break;

		        default:
		            title
						.css({
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'paddingLeft': currentOpts.padding,
						    'paddingRight': currentOpts.padding
						})
						.appendTo(wrap);
		            break;
		    }

		    title.hide();
		},

		_set_navigation = function () {
		    if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
		        $(document).bind('keydown.fb', function (e) {
		            if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
		                e.preventDefault();
		                $.fancybox.close();

		            } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
		                e.preventDefault();
		                $.fancybox[e.keyCode == 37 ? 'prev' : 'next']();
		            }
		        });
		    }

		    if (!currentOpts.showNavArrows) {
		        nav_left.hide();
		        nav_right.hide();
		        return;
		    }

		    if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
		        nav_left.show();
		    }

		    if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length - 1)) {
		        nav_right.show();
		    }
		},

		_finish = function () {
		    if (!$.support.opacity) {
		        content.get(0).style.removeAttribute('filter');
		        wrap.get(0).style.removeAttribute('filter');
		    }

		    if (selectedOpts.autoDimensions) {
		        content.css('height', 'auto');
		    }

		    wrap.css('height', 'auto');

		    if (titleStr && titleStr.length) {
		        title.show();
		    }

		    if (currentOpts.showCloseButton) {
		        close.show();
		    }

		    _set_navigation();

		    if (currentOpts.hideOnContentClick) {
		        content.bind('click', $.fancybox.close);
		    }

		    if (currentOpts.hideOnOverlayClick) {
		        overlay.bind('click', $.fancybox.close);
		    }

		    $(window).bind("resize.fb", $.fancybox.resize);

		    if (currentOpts.centerOnScroll) {
		        $(window).bind("scroll.fb", $.fancybox.center);
		    }

		    if (currentOpts.type == 'iframe') {
		        $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
		    }

		    wrap.show();

		    busy = false;

		    $.fancybox.center();

		    currentOpts.onComplete(currentArray, currentIndex, currentOpts);

		    _preload_images();
		},

		_preload_images = function () {
		    var href,
				objNext;

		    if ((currentArray.length - 1) > currentIndex) {
		        href = currentArray[currentIndex + 1].href;

		        if (typeof href !== 'undefined' && href.match(imgRegExp)) {
		            objNext = new Image();
		            objNext.src = href;
		        }
		    }

		    if (currentIndex > 0) {
		        href = currentArray[currentIndex - 1].href;

		        if (typeof href !== 'undefined' && href.match(imgRegExp)) {
		            objNext = new Image();
		            objNext.src = href;
		        }
		    }
		},

		_draw = function (pos) {
		    var dim = {
		        width: parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
		        height: parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),

		        top: parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
		        left: parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
		    };

		    if (typeof final_pos.opacity !== 'undefined') {
		        dim.opacity = pos < 0.5 ? 0.5 : pos;
		    }

		    wrap.css(dim);

		    content.css({
		        'width': dim.width - currentOpts.padding * 2,
		        'height': dim.height - (titleHeight * pos) - currentOpts.padding * 2
		    });
		},

		_get_viewport = function () {
		    return [
				$(window).width() - (currentOpts.margin * 2),
				$(window).height() - (currentOpts.margin * 2),
				$(document).scrollLeft() + currentOpts.margin,
				$(document).scrollTop() + currentOpts.margin
			];
		},

		_get_zoom_to = function () {
		    var view = _get_viewport(),
				to = {},
				resize = currentOpts.autoScale,
				double_padding = currentOpts.padding * 2,
				ratio;

		    if (currentOpts.width.toString().indexOf('%') > -1) {
		        to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
		    } else {
		        to.width = currentOpts.width + double_padding;
		    }

		    if (currentOpts.height.toString().indexOf('%') > -1) {
		        to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
		    } else {
		        to.height = currentOpts.height + double_padding;
		    }

		    if (resize && (to.width > view[0] || to.height > view[1])) {
		        if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
		            ratio = (currentOpts.width) / (currentOpts.height);

		            if ((to.width) > view[0]) {
		                to.width = view[0];
		                to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
		            }

		            if ((to.height) > view[1]) {
		                to.height = view[1];
		                to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
		            }

		        } else {
		            to.width = Math.min(to.width, view[0]);
		            to.height = Math.min(to.height, view[1]);
		        }
		    }

		    to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
		    to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);

		    return to;
		},

		_get_obj_pos = function (obj) {
		    var pos = obj.offset();

		    pos.top += parseInt(obj.css('paddingTop'), 10) || 0;
		    pos.left += parseInt(obj.css('paddingLeft'), 10) || 0;

		    pos.top += parseInt(obj.css('border-top-width'), 10) || 0;
		    pos.left += parseInt(obj.css('border-left-width'), 10) || 0;

		    pos.width = obj.width();
		    pos.height = obj.height();

		    return pos;
		},

		_get_zoom_from = function () {
		    var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
				from = {},
				pos,
				view;

		    if (orig && orig.length) {
		        pos = _get_obj_pos(orig);

		        from = {
		            width: pos.width + (currentOpts.padding * 2),
		            height: pos.height + (currentOpts.padding * 2),
		            top: pos.top - currentOpts.padding - 20,
		            left: pos.left - currentOpts.padding - 20
		        };

		    } else {
		        view = _get_viewport();

		        from = {
		            width: currentOpts.padding * 2,
		            height: currentOpts.padding * 2,
		            top: parseInt(view[3] + view[1] * 0.5, 10),
		            left: parseInt(view[2] + view[0] * 0.5, 10)
		        };
		    }

		    return from;
		},

		_animate_loading = function () {
		    if (!loading.is(':visible')) {
		        clearInterval(loadingTimer);
		        return;
		    }

		    $('div', loading).css('top', (loadingFrame * -40) + 'px');

		    loadingFrame = (loadingFrame + 1) % 12;
		};

    /*
    * Public methods 
    */

    $.fn.fancybox = function (options) {
        if (!$(this).length) {
            return this;
        }

        $(this)
			.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
			.unbind('click.fb')
			.bind('click.fb', function (e) {
			    e.preventDefault();

			    if (busy) {
			        return;
			    }

			    busy = true;

			    $(this).blur();

			    selectedArray = [];
			    selectedIndex = 0;

			    var rel = $(this).attr('rel') || '';

			    if (!rel || rel == '' || rel === 'nofollow') {
			        selectedArray.push(this);

			    } else {
			        selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
			        selectedIndex = selectedArray.index(this);
			    }

			    _start();

			    return;
			});

        return this;
    };

    $.fancybox = function (obj) {
        var opts;

        if (busy) {
            return;
        }

        busy = true;
        opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};

        selectedArray = [];
        selectedIndex = parseInt(opts.index, 10) || 0;

        if ($.isArray(obj)) {
            for (var i = 0, j = obj.length; i < j; i++) {
                if (typeof obj[i] == 'object') {
                    $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
                } else {
                    obj[i] = $({}).data('fancybox', $.extend({ content: obj[i] }, opts));
                }
            }

            selectedArray = jQuery.merge(selectedArray, obj);

        } else {
            if (typeof obj == 'object') {
                $(obj).data('fancybox', $.extend({}, opts, obj));
            } else {
                obj = $({}).data('fancybox', $.extend({ content: obj }, opts));
            }

            selectedArray.push(obj);
        }

        if (selectedIndex > selectedArray.length || selectedIndex < 0) {
            selectedIndex = 0;
        }

        _start();
    };

    $.fancybox.showActivity = function () {
        clearInterval(loadingTimer);

        loading.show();
        loadingTimer = setInterval(_animate_loading, 66);
    };

    $.fancybox.hideActivity = function () {
        loading.hide();
    };

    $.fancybox.next = function () {
        return $.fancybox.pos(currentIndex + 1);
    };

    $.fancybox.prev = function () {
        return $.fancybox.pos(currentIndex - 1);
    };

    $.fancybox.pos = function (pos) {
        if (busy) {
            return;
        }

        pos = parseInt(pos);

        selectedArray = currentArray;

        if (pos > -1 && pos < currentArray.length) {
            selectedIndex = pos;
            _start();

        } else if (currentOpts.cyclic && currentArray.length > 1) {
            selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
            _start();
        }

        return;
    };

    $.fancybox.cancel = function () {
        if (busy) {
            return;
        }

        busy = true;

        $.event.trigger('fancybox-cancel');

        _abort();

        selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);

        busy = false;
    };

    // Note: within an iframe use - parent.$.fancybox.close();
    $.fancybox.close = function () {
        if (busy || wrap.is(':hidden')) {
            return;
        }

        busy = true;

        if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
            busy = false;
            return;
        }

        _abort();

        $(close.add(nav_left).add(nav_right)).hide();

        $(content.add(overlay)).unbind();

        $(window).unbind("resize.fb scroll.fb");
        $(document).unbind('keydown.fb');

        content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');

        if (currentOpts.titlePosition !== 'inside') {
            title.empty();
        }

        wrap.stop();

        function _cleanup() {
            overlay.fadeOut('fast');

            title.empty().hide();
            wrap.hide();

            $.event.trigger('fancybox-cleanup');

            content.empty();

            currentOpts.onClosed(currentArray, currentIndex, currentOpts);

            currentArray = selectedOpts = [];
            currentIndex = selectedIndex = 0;
            currentOpts = selectedOpts = {};

            busy = false;
        }

        if (currentOpts.transitionOut == 'elastic') {
            start_pos = _get_zoom_from();

            var pos = wrap.position();

            final_pos = {
                top: pos.top,
                left: pos.left,
                width: wrap.width(),
                height: wrap.height()
            };

            if (currentOpts.opacity) {
                final_pos.opacity = 1;
            }

            title.empty().hide();

            fx.prop = 1;

            $(fx).animate({ prop: 0 }, {
                duration: currentOpts.speedOut,
                easing: currentOpts.easingOut,
                step: _draw,
                complete: _cleanup
            });

        } else {
            wrap.fadeOut(currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
        }
    };

    $.fancybox.resize = function () {
        if (overlay.is(':visible')) {
            overlay.css('height', $(document).height());
        }

        $.fancybox.center(true);
    };

    $.fancybox.center = function () {
        var view, align;

        if (busy) {
            return;
        }

        align = arguments[0] === true ? 1 : 0;
        view = _get_viewport();

        if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
            return;
        }

        wrap
			.stop()
			.animate({
			    'top': parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
			    'left': parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
			}, typeof arguments[0] == 'number' ? arguments[0] : 200);
    };

    $.fancybox.init = function () {
        if ($("#fancybox-wrap").length) {
            return;
        }

        $('body').append(
			tmp = $('<div id="fancybox-tmp"></div>'),
			loading = $('<div id="fancybox-loading"><div></div></div>'),
			overlay = $('<div id="fancybox-overlay"></div>'),
			wrap = $('<div id="fancybox-wrap"></div>')
		);

        outer = $('<div id="fancybox-outer"></div>')
			.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
			.appendTo(wrap);

        outer.append(
			content = $('<div id="fancybox-content"></div>'),
			close = $('<a id="fancybox-close"></a>'),
			title = $('<div id="fancybox-title"></div>'),

			nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
			nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
		);

        close.click($.fancybox.close);
        loading.click($.fancybox.cancel);

        nav_left.click(function (e) {
            e.preventDefault();
            $.fancybox.prev();
        });

        nav_right.click(function (e) {
            e.preventDefault();
            $.fancybox.next();
        });

        if ($.fn.mousewheel) {
            wrap.bind('mousewheel.fb', function (e, delta) {
                if (busy) {
                    e.preventDefault();

                } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
                    e.preventDefault();
                    $.fancybox[delta > 0 ? 'prev' : 'next']();
                }
            });
        }

        if (!$.support.opacity) {
            wrap.addClass('fancybox-ie');
        }

        if (isIE6) {
            loading.addClass('fancybox-ie6');
            wrap.addClass('fancybox-ie6');

            $('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank') + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
        }
    };

    $.fn.fancybox.defaults = {
        padding: 10,
        margin: 40,
        opacity: false,
        modal: false,
        cyclic: false,
        scrolling: 'auto', // 'auto', 'yes' or 'no'

        width: 560,
        height: 340,

        autoScale: true,
        autoDimensions: true,
        centerOnScroll: false,

        ajax: {},
        swf: { wmode: 'transparent' },

        hideOnOverlayClick: true,
        hideOnContentClick: false,

        overlayShow: true,
        overlayOpacity: 0.7,
        overlayColor: '#777',

        titleShow: true,
        titlePosition: 'float', // 'float', 'outside', 'inside' or 'over'
        titleFormat: null,
        titleFromAlt: false,

        transitionIn: 'fade', // 'elastic', 'fade' or 'none'
        transitionOut: 'fade', // 'elastic', 'fade' or 'none'

        speedIn: 300,
        speedOut: 300,

        changeSpeed: 300,
        changeFade: 'fast',

        easingIn: 'swing',
        easingOut: 'swing',

        showCloseButton: true,
        showNavArrows: true,
        enableEscapeButton: true,
        enableKeyboardNav: true,

        onStart: function () { },
        onCancel: function () { },
        onComplete: function () { },
        onCleanup: function () { },
        onClosed: function () { },
        onError: function () { }
    };

    $(document).ready(function () {
        $.fancybox.init();
    });

})(jQuery);$(document).ready(function() {
	$("a.thickbox").fancybox();
}); 
/*
 * SimpleModal 1.3 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * Copyright (c) 2009 Eric Martin
 * Dual licensed under the MIT and GPL licenses
 * Revision: $Id: jquery.simplemodal.js 205 2009-06-12 13:29:21Z emartin24 $
 */
;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},autoResize:false,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:true,position:null,persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}ieQuirks=$.browser.msie&&!$.boxModel;this.opts=$.extend({},$.modal.defaults,options);this.zIndex=this.opts.zIndex;this.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div/>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return false;}this.create(data);data=null;this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}return this;},create:function(data){w=this.getDimensions();if(ie6){this.dialog.iframe=$('<iframe src="javascript:false;"/>').css($.extend(this.opts.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:this.opts.zIndex,top:0,left:0})).appendTo(this.opts.appendTo);}this.dialog.overlay=$('<div/>').attr('id',this.opts.overlayId).addClass('simplemodal-overlay').css($.extend(this.opts.overlayCss,{display:'none',opacity:this.opts.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:this.opts.zIndex+1})).appendTo(this.opts.appendTo);this.dialog.container=$('<div/>').attr('id',this.opts.containerId).addClass('simplemodal-container').css($.extend(this.opts.containerCss,{display:'none',position:'fixed',zIndex:this.opts.zIndex+2})).append(this.opts.close&&this.opts.closeHTML?$(this.opts.closeHTML).addClass(this.opts.closeClass):'').appendTo(this.opts.appendTo);this.dialog.wrap=$('<div/>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(this.dialog.container);this.dialog.data=data.attr('id',data.attr('id')||this.opts.dataId).addClass('simplemodal-data').css($.extend(this.opts.dataCss,{display:'none'}));data=null;this.setContainerDimensions();this.dialog.data.appendTo(this.dialog.wrap);if(ie6||ieQuirks){this.fixIE();}},bindEvents:function(){var self=this;$('.'+self.opts.closeClass).bind('click.simplemodal',function(e){e.preventDefault();self.close();});if(self.opts.close&&self.opts.overlayClose){self.dialog.overlay.bind('click.simplemodal',function(e){e.preventDefault();self.close();});}$(document).bind('keydown.simplemodal',function(e){if(self.opts.focus&&e.keyCode==9){self.watchTab(e);}else if((self.opts.close&&self.opts.escClose)&&e.keyCode==27){e.preventDefault();self.close();}});$(window).bind('resize.simplemodal',function(){w=self.getDimensions();self.opts.autoResize?self.setContainerDimensions():self.setPosition();if(ie6||ieQuirks){self.fixIE();}else{self.dialog.iframe&&self.dialog.iframe.css({height:w[0],width:w[1]});self.dialog.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.dialog.overlay.unbind('click.simplemodal');},fixIE:function(){var p=this.opts.position;$.each([this.dialog.iframe||null,this.dialog.overlay,this.dialog.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var self=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,self.dialog.wrap);input.length>0?input.focus():self.dialog.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:parseInt(v.replace(/px/,''));},setContainerDimensions:function(){var ch=this.getVal(this.dialog.container.css('height')),cw=this.dialog.container.width(),dh=this.dialog.data.height(),dw=this.dialog.data.width();var mh=this.opts.maxHeight&&this.opts.maxHeight<w[0]?this.opts.maxHeight:w[0],mw=this.opts.maxWidth&&this.opts.maxWidth<w[1]?this.opts.maxWidth:w[1];if(!ch){if(!dh){ch=this.opts.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<this.opts.minHeight){ch=this.opts.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=this.opts.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<this.opts.minWidth){cw=this.opts.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}this.dialog.container.css({height:ch,width:cw});if(dh>ch||dw>cw){this.dialog.wrap.css({overflow:'auto'});}this.setPosition();},setPosition:function(){var top,left,hc=(w[0]/2)-((this.dialog.container.height()||this.dialog.data.height())/2),vc=(w[1]/2)-((this.dialog.container.width()||this.dialog.data.width())/2);if(this.opts.position&&this.opts.position.constructor==Array){top=this.opts.position[0]||hc;left=this.opts.position[1]||vc;}else{top=hc;left=vc;}this.dialog.container.css({left:left,top:top});},watchTab:function(e){var self=this;if($(e.target).parents('.simplemodal-container').length>0){self.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',self.dialog.data);if(!e.shiftKey&&e.target==self.inputs[self.inputs.length-1]||e.shiftKey&&e.target==self.inputs[0]||self.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){self.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){self.focus();},10);}},open:function(){this.dialog.iframe&&this.dialog.iframe.show();if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}this.focus();this.bindEvents();},close:function(){if(!this.dialog.data){return false;}this.unbindEvents();if($.isFunction(this.opts.onClose)&&!this.occb){this.occb=true;this.opts.onClose.apply(this,[this.dialog]);}else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}else{this.dialog.data.hide().remove();this.dialog.orig.appendTo(this.dialog.parentNode);}}else{this.dialog.data.hide().remove();}this.dialog.container.hide().remove();this.dialog.overlay.hide().remove();this.dialog.iframe&&this.dialog.iframe.hide().remove();this.dialog={};}}};})(jQuery);// Div-adjustments.js
//HACK: Please try to move this to Adjust-Height.js style.
var offSetHeight = 10;
function FixHeight(one, two) {
    if ($('#' + one)) {
        var lh = $('#' + one).height();
        var rh = $('#' + two).height();
        var nh = Math.max(lh, rh);
        $('#' + one).height(nh + offSetHeight);
        $('#' + two).height(nh + offSetHeight);
    }
}
function AdjustHeight()
{
    if($("#two-left"))
    {
        $("#two-left").css("minHeight",$("#two-content").attr("offsetHeight") + offSetHeight + "px");
        if (IsIE6Browser()) 
        {
            $("#two-left").css("height",$("#two-content").attr("offsetHeight") + "px");
        }
        else
        {
             $("#two-left").css("height","auto");
        }
    }
}
function IsIE6Browser()
{
    var returnResult = false;
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    if ((version == 6) && (document.body.filters)) 
    {
        returnResult = true;
    }
    return returnResult;
  
}
function ReAssignHieght(id,orginalHeight,value)
{
        var newheight = orginalHeight + value;
        $('#'+id).css("height", newheight+"px");
}
function AdjustDesignHeight()
{
    if ($("#rndFashionDesign-content")) 
    {     
        var prefixedID = $("#hdnRandomDesignPrefixedID").val() + "_";
        $('#'+prefixedID + "ulRndFashionDesign").css('display','block');  
        if (! IsIE6Browser())
        {
            $("#rndFashionDesign-left").height($("#divFDRandomPanel").height() + 10);
            $("#rndFashionDesign-right").height($("#rndFashionDesign-left").height());
        }
	}
}
//googlecse.js
$(function() {  
var q = $("#q");
var qSubmit = $("#qSubmit");
q.keypress(function (e) {  
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {  
            qSubmit.trigger("click");
		return false;  
	} else {
		return true;  
	}
});
    var qBlur = function () {
	if (q.val() == '') {
		q.addClass("search-watermark");
        }
};
    q.bind("focus", function () {
	q.removeClass("search-watermark");
});
    q.bind("blur", qBlur);
    qSubmit.bind("click", function (e) {
        location.href = "/search/index.aspx?q=" + q.val();
    });
    qBlur();
});
