/**
* Copyright (c) 2007, Impact Proximity
* All rights reserved.
* @author Ali Akhtar <m.ali@impactbbdo.ae>
* @version 1.0.1
*/

$(function(){

	//global vars
	var locale = "en_gb";
	if(window.location.href.indexOf("ar_ae"))
	locale = "ar_ae";
	
	var isIE = $.browser.msie;
	var isIE6 = isIE && ($.browser.version == 6.0);
	var isIE7 = isIE && ($.browser.version == 7.0);
	
	//add 'FirstChild' and sfhover class for ie6 */
	var firstChild = function(){
		$("li:first-child").addClass("FirstChild");
	}
	var lastChild = function(){
		$("li:last-child").addClass("LastChild");
	}
	if($.browser.msie && $.browser.version == "6.0") {
		firstChild();
	}
	// add LastChild class to IE
	if(isIE){
		lastChild();
	}
	
	var externalLinks = function(){
 $('a[rel=external]').bind('click',function(){$(this).attr('target','_blank')});
 }
 externalLinks();
	
	//auto text handler
	$("div.Header input.Textbox,div.OMDebate textarea,div.Question input.Textbox")
	.each(function(){
		var autoText = "";
		var defaultText = $(this).val();
		$(this).bind('focus',function(){
		autoText = $(this).val();
		if(autoText == defaultText) $(this).val("");
		})
		.bind('blur',function(){
			if($(this).val() == "")
			$(this).val(defaultText);
		});
	});
	
	function flashPopup($location){
	 var left = (screen.width/2) - 200;
		var top = (screen.height/2) - 350;
		var popup;
		popup = window.open($location,"popup","width=345,height=495,left="+left+",top="+top+"");
		if(popup.name == "popup" && popup.focus) popup.focus();
	};
	
	var test = function(){
		$("a[rel=popup]").bind("click",function(){
		 $location = this.href;
			flashPopup($location);
			return false;
		})
		}
		test();
		
		var $popop1 = function(){
		$("a[rel=popup1]").bind("click",function(){
			var left = (screen.width/2) - 300;
			var top = (screen.height/2) - 350;
			var popup;
			popup = window.open(this.href,"popup","width=660,height=600,scrollbars=yes,menubar=no,location=no,left="+left+",top="+top+"");
			if(popup.name == "popup" && popup.focus) popup.focus();
			return false;
		})
		}
		$popop1();
		
		var $popop2 = function(){
		$("a[rel=popup2]").bind("click",function(){
			var left = (screen.width/2) - 300;
			var top = (screen.height/2) - 350;
			var popup;
			popup = window.open(this.href,"popup","width=660,height=600,scrollbars=yes,menubar=no,location=no,left="+left+",top="+top+"");
			if(popup.name == "popup" && popup.focus) popup.focus();
			return false;
		})
		}
		$popop2();
		
		var $print = function(){
		 $('.Print a').click(function(){
		  window.print();
		  return false;
		 }); 
		}
		$print();
	
});


