var GT_DEFAULT_BACKGROUND = "css/bg/std1.jpg";
function gt_set_bg(urlOfBg){
	jQuery("body").css("background-image","url("+urlOfBg+")").css("background-position","top center").css("background-repeat","no-repeat");
}
function initGyazilimPage(){
	jQuery("#epostaKayitInput").focus(function() {
		jQuery(this).addClass("focusedInput");
		if (jQuery(this).attr("title")==jQuery(this).attr("value")){ jQuery(this).attr("value",""); }
	}).blur(function() {
		jQuery(this).removeClass("focusedInput");
		if (jQuery(this).attr("value")==""){ jQuery(this).attr("value",jQuery(this).attr("title")); }
	});
	jQuery("#epostaKayitBtn").click(function(){
		var urlForLink = jQuery("#epostaKayitBtn").attr("href");
		window.location = urlForLink+"&eposta="+encodeURI(jQuery("#epostaKayitInput").attr("value"));
		return false; 
	});
}
function initGyazilimIframeLinks(selectorString){
	jQuery('a.uzaksayfa').each( function(index,el){
		var defW = 900;
		var defH = 650;
		var strHref = jQuery(el).attr("href");
		var tempW   = gtGetParam(strHref,"iw",10);
		var tempH   = gtGetParam(strHref,"ih",10);
		if (tempW!=null && tempH!=null && tempW>100 && tempH>100){
			defW = tempW;defH = tempH;
		}		
		jQuery(el).colorbox({ iframe:true,width:defW,height:defH });
	});
	
}
function gtGetParam(strHref,strParamName,defVal){
	if ( strHref && strHref.indexOf("?") > -1 ){
		if (strHref.indexOf("?")>0){
			var strQueryString = strHref.substr(strHref.indexOf("?")+1);
			qString = strQueryString.split("&");
			for (var i=0;i<qString.length; i++){
				if (escape(unescape(qString[i].split("=")[0])) == strParamName){
					return  qString[i].split("=")[1];
				}				
			}			
		}		
	}	
	return defVal;
}
jQuery.fn.extend({
	/**
	* Returns get parameters.
	*
	* If the desired param does not exist, null will be returned
	*
	* To get the document params:
	* @example value = $(document).getUrlParam("paramName");
	* 
	* To get the params of a html-attribut (uses src attribute)
	* @example value = $('#imgLink').getUrlParam("paramName");
	*/ 
	 getUrlParam: function(strParamName){
		  strParamName = escape(unescape(strParamName));
		  
		  var returnVal = new Array();
		  var qString = null;
		  
		  if ($(this).attr("nodeName")=="#document") {
		  	//document-handler
			
			if (window.location.search.search(strParamName) > -1 ){
				
				qString = window.location.search.substr(1,window.location.search.length).split("&");
			}
				
		  } else if (jQuery(this).attr("src")!="undefined" && jQuery(this).attr("src")!="") {
		  	
		  	var strHref = jQuery(this).attr("src");
		  	if ( strHref && strHref.indexOf("?") > -1 ){
		    	var strQueryString = strHref.substr(strHref.indexOf("?")+1);
		  		qString = strQueryString.split("&");
		  	}
		  } else if ($(this).attr("href")!="undefined" && $(this).attr("href")!="") {		  	
		  	var strHref = jQuery(this).attr("href")
		  	if ( strHref && strHref.indexOf("?") > -1 ){
		    	var strQueryString = strHref.substr(strHref.indexOf("?")+1);
		  		qString = strQueryString.split("&");
		  	}
		  } else {
		  	return null;
		  }		  			  
		  if (qString==null) return null;		 		  
		  for (var i=0;i<qString.length; i++){
				if (escape(unescape(qString[i].split("=")[0])) == strParamName){
					returnVal.push(qString[i].split("=")[1]);
				}
				
		  }
		  if (returnVal.length==0) return null;
		  else if (returnVal.length==1) return returnVal[0];
		  else return returnVal;
		}
	});
