var $j = jQuery.noConflict(); // To make sure the Jquery will not conflict with other librarys
var varsToPass = "";

var HTTP_HOST = "leefiltersusa.4t2servers.com";

//Get url Parameters. Javascript doesn't supply an easy way of doing this like PHP - $_GET[], $_POST[]
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf(":") > -1 ){
	var strQueryString = strHref.substr(strHref.indexOf(":")).toLowerCase();
	var aQueryString = strQueryString.split("/");
	for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	  if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + ":") > -1 ){
		var aParam = aQueryString[iParam].split(":");
		strReturn = aParam[1];
		break;
	  }
	}
  }
  return unescape(strReturn);
} 

var varsToPass = "currentTab:"+getURLParam("currentTab");

$j(document).ready(function() {		
	var tabselected = getURLParam("changeTab");
	var tabActSelected = getURLParam("req");
	var table = getURLParam("tableOption");
	var currentTab = getURLParam("currentTab");

	if ((currentTab == "thumbview") || (tabselected == "getcolor") || (tabActSelected == "lightbox") && (table != "gobos"))
	{
		var showTab = 1;
	}
	else
	{
		var showTab = 0;
	}

	/* ######## Update the color list when user selects a color list from drop down box in right hand menu, when logged in ########### 
	$j("#lightBoxRH").change(function () {		
		var str = "";
		str = $j(this).val();
		$j.post("/functions/lightBoxActions.php",{ act: "changeActiveLightbox", ref: ""+str+"", colorDetails: "true" },
			function(data){
				window.location.reload();
		});
	});
	 ######## End drop down list ########## */


	/* ############ Editable text box from a text label ############ */
	$j(".edit").mouseover(function() { 
		$j(this).css('background-color', '#FFF1CA');
	});
    $j(".edit").mouseout(function() { 
        $j(this).css('background-color', 'transparent');
    });
	$j(".edit").editable("http://"+HTTP_HOST+"/functions/lightBoxActions.php?act=saveName", {
		indicator : "Saving...",
		select : true,
		cancel    : 'Cancel',
		submit    : 'OK',
		tooltip   : 'Click to rename...',
		callback  : function(value, settings) {
		window.location.reload();
		}
	});

	$j(".lightboxNameNew").editable("http://"+HTTP_HOST+"/functions/lightBoxActions.php?act=saveName&ref=new", {
		indicator : "Creating...",
		select : true,
		cancel    : 'Cancel',
		submit    : 'OK',
		tooltip   : 'Click to add new...',
		callback  : function(value, settings) {
		window.location.reload();
		}

	});
	/* ############# End Editable text box ############# */


	/* ########  Sliding effect for login Register panel on right hand side ############ */
	//hide the all of the element with class pane_body
	$j(".pane_body").hide();
	//slides the element with class "pane_body" when paragraph with class "pane_head" is clicked
	$j("#pane p.pane_head").click(function()
	{
		if ($j("div.pane_body").is(":hidden")) {
			$j(this).css({backgroundImage:"url(/images/template/bars/black-active.gif)"}).next("div.pane_body").slideDown(300);
		} else {
			$j(this).css({backgroundImage:"url(/images/template/bars/black.gif)"}).next("div.pane_body").slideUp(300);
		}
	});

	$j("#pane2 .pane_body").show();
	$j("#pane2 p.pane_head").css({backgroundImage:"url(/images/template/bars/black-active.gif)"});
	//slides the element with class "pane_body" when paragraph with class "pane_head" is clicked
	$j("#pane2 p.pane_head").click(function()
	{
		if ($j("#pane2 div.pane_body").is(":hidden")) {
			$j(this).css({backgroundImage:"url(/images/template/bars/black-active.gif)"}).next("#pane2 div.pane_body").slideDown(300);
		} else {
			$j(this).css({backgroundImage:"url(/images/template/bars/black.gif)"}).next("#pane2 div.pane_body").slideUp(300);
		}
	});
	/* ######### End right hand login register ############### */

	$j('#prodBox > ul').tabs({
		/*select: function(event, ui) {
			alert(ui.tab);
		},*/
			selected: showTab
	});	

	$j("#keywords").focus(function() 
	{
		if (this.value == this.defaultValue ) 
		{
			this.value = "";
		}
	}).blur(function() 
	{
		if (!this.value.length ) 
		{
			this.value = this.defaultValue;
		}
	});	

    $j("#tableOption").change(function () 
	{	
		
		var str = "";
		str = $j(this).val();
		
		if ((str == "colors") || (str == ""))
		{
			$j("#rangesOption").show();
		}
		else
		{
			$j("#rangesOption").hide();
		}
		/*
		$("#tableOption select option:selected").each(function () {
			str = $(this).text();
		});
		*/
	})
	.change();

});