var trueroots_site_us = "www.trueroots.us";
var trueroots_site_ca = "www.trueroots.ca";
var trueroots_site_uk = "www.trueroots.co.uk";
var trueroots_site_hk = "www.trueroots.hk";
var trueroots_site_sg = "www.trueroots.sg";
var trueroots_site_de = "www.trueroots.eu";
var trueroots_site_fr = "www.trueroots.eu";

function popup() {

newWindow = window.open('http://www.trueroots.co.uk/calling/roaming_popup','newWin','width=708,height=291','fullscreen=no');
//setTimeout('closeWin(newWindow)', 5000);	// delay 5 seconds before closing
//wWindow.focus();
newWindow.blur();

//newwindow=window.open(url,'name','height=400,width=200');
//if (window.focus) {newwindow.focus()}

}

$(document).ready(function() {

      /*       	if(location.href=='http://'+document.domain+'/' || location.href=='http://'+document.domain+'/home' || location.href=='https://'+document.domain+'/' || location.href=='https://'+document.domain+'/home'){
              if(Stop_Img!="Stop"){ slideit() }
              document.getElementById("watch_live").style.display = 'none';
			  }
    */
		$("#site_selector").change(function() {
				var index1 = $("#site_selector")[0].selectedIndex;
				goto_site(document.getElementById('site_selector').options[index1].value);
		});
		
		
		$('#cancel_session').click(function() {
			if (confirm('Are you sure you want to cancel your order?')) {
				window.location = '/home';
			}
			return false;
		});
	}
);


function text_font() {
 document.getElementById('tone').className='font5';
 document.getElementById('ttwo').className='font5';
 document.getElementById('tthree').className='font5';
 document.getElementById('tfour').className='font5';
 document.getElementById('tfive').className='font5';

} 

function rate_one(){
	text_font();
	//document.getElementById('tone').className='fontt55';
	document.getElementById("mid_tab1").style.display = "";
	document.getElementById("mid_tab2").style.display = 'none';
	document.getElementById("mid_tab3").style.display = 'none';
	document.getElementById("mid_tab4").style.display = 'none';
	document.getElementById("mid_tab5").style.display = 'none';
}

function rate_two(){
	text_font();
	//document.getElementById('ttwo').className='fontt55';
	document.getElementById("mid_tab1").style.display = "none";
	document.getElementById("mid_tab2").style.display = '';
	document.getElementById("mid_tab3").style.display = 'none';
	document.getElementById("mid_tab4").style.display = 'none';
	document.getElementById("mid_tab5").style.display = 'none';
}

function rate_three(){
	text_font();
	//document.getElementById('tthree').className='fontt55';
	document.getElementById("mid_tab1").style.display = "none";
	document.getElementById("mid_tab2").style.display = 'none';
	document.getElementById("mid_tab3").style.display = '';
	document.getElementById("mid_tab4").style.display = 'none';
	document.getElementById("mid_tab5").style.display = 'none';
}

function rate_four(){
	text_font();
	//document.getElementById('tfour').className='fontt55';
	document.getElementById("mid_tab1").style.display = "none";
	document.getElementById("mid_tab2").style.display = 'none';
	document.getElementById("mid_tab3").style.display = 'none';
	document.getElementById("mid_tab4").style.display = '';
	document.getElementById("mid_tab5").style.display = 'none';
}

function rate_five(){
	text_font();
	//document.getElementById('tfive').className='fontt55';
	document.getElementById("mid_tab1").style.display = "none";
	document.getElementById("mid_tab2").style.display = 'none';
	document.getElementById("mid_tab3").style.display = 'none';
	document.getElementById("mid_tab4").style.display = 'none';
	document.getElementById("mid_tab5").style.display = '';
}

function watch_live(){
	
	document.getElementById("watch_live").style.display = "";
	document.getElementById("social_network").style.display = 'none';
	document.getElementById("watch_ramdan").style.display = "none";

}

function show_social(){
	
	document.getElementById("social_network").style.display = "";
	document.getElementById("watch_live").style.display = 'none';
	document.getElementById("watch_ramdan").style.display = "none";

}

function watch_ramdan(){
	
	document.getElementById("watch_ramdan").style.display = "";
	document.getElementById("watch_live").style.display = 'none';
	document.getElementById("social_network").style.display = 'none';

}

function plan_view(plan){
   var index1 = $("#site_selector")[0].selectedIndex;
   if(plan=='1'){
		document.getElementById("gen_plan").style.display = "";
		document.getElementById("plus1").style.display = "none";
		document.getElementById("minus1").style.display = "";
		plan_hid(2); plan_hid(5);plan_hid(7);
		// plan_hid(3);
		plan_hid(33);
		if(index1==2){ plan_hid(4); }
   }else if(plan=='2'){
		document.getElementById("true_plan").style.display = "";
		document.getElementById("plus2").style.display = "none";
		document.getElementById("minus2").style.display = "";	
		plan_hid(1); plan_hid(5);plan_hid(7);
		// plan_hid(3);
		plan_hid(33);
		if(index1==2){ plan_hid(4); }		
   }else if(plan=='33'){
		document.getElementById("bogo200_plan").style.display = "";
		document.getElementById("plus33").style.display = "none";
		document.getElementById("minus33").style.display = "";	 
		plan_hid(2); plan_hid(1); plan_hid(5);	plan_hid(7);
		
		if(index1==2){ plan_hid(4); }		
		//document.getElementById("hname").style.height = "590px";
   }else if(plan=='4'){
		document.getElementById("stretch_plan").style.display = "";
		document.getElementById("plus4").style.display = "none";
		document.getElementById("minus4").style.display = "";	
		plan_hid(2); plan_hid(1); plan_hid(5);plan_hid(7);
		// plan_hid(3);
		plan_hid(33);
   }else if(plan=='5'){
		document.getElementById("trueone_plan").style.display = "";
		document.getElementById("plus5").style.display = "none";
		document.getElementById("minus5").style.display = "";
		plan_hid(2); plan_hid(1);plan_hid(7);
		// plan_hid(3); 
		plan_hid(33);
		if(index1==2){ plan_hid(4); }
   }else if(plan=='7'){
		document.getElementById("hot_line_plan").style.display = "";
		document.getElementById("plus7").style.display = "none";
		document.getElementById("minus7").style.display = "";
		plan_hid(2); plan_hid(1);plan_hid(5);
		// plan_hid(3); 
		plan_hid(33);
		if(index1==2){ plan_hid(4); }
   }
} 

function plan_hid(plan){
   if(plan=='1'){
		document.getElementById("gen_plan").style.display = "none";
		document.getElementById("plus1").style.display = "";
		document.getElementById("minus1").style.display = "none";
   }else if(plan=='2'){
		document.getElementById("true_plan").style.display = "none";
		document.getElementById("plus2").style.display = "";
		document.getElementById("minus2").style.display = "none";
   }else if(plan=='33'){
		document.getElementById("bogo200_plan").style.display = "none";
		document.getElementById("plus33").style.display = "";
		document.getElementById("minus33").style.display = "none";
		//document.getElementById("hname").style.height = "500px";
   }else if(plan=='4'){
		document.getElementById("stretch_plan").style.display = "none";
		document.getElementById("plus4").style.display = "";
		document.getElementById("minus4").style.display = "none";
   }else if(plan=='5'){
		document.getElementById("trueone_plan").style.display = "none";
		document.getElementById("plus5").style.display = "";
		document.getElementById("minus5").style.display = "none";
   }else if(plan=='7'){
		document.getElementById("hot_line_plan").style.display = "none";
		document.getElementById("plus7").style.display = "";
		document.getElementById("minus7").style.display = "none";
		//document.getElementById("hname").style.height = "500px";
   }
}



function goto_site(id) {
	var sites = new Array();
	sites['US'] = trueroots_site_us;
	sites['CA'] = trueroots_site_ca;
	sites['UK'] = trueroots_site_uk;
	sites['HK'] = trueroots_site_hk;
	sites['SG'] = trueroots_site_sg;
	sites['EU'] = trueroots_site_de;
	sites['EU'] = trueroots_site_fr;

	window.location = window.location.protocol + "//" + sites[id] + window.location.pathname;
}


function input_hover(id, bg_regular, bg_hover) {
	var button = $('#' + id);
	button.mouseover(function() {
		button.css('background-image', 'url(' + bg_hover + ')');
	});
	button.mouseout(function() {
		button.css('background-image', 'url(' + bg_regular + ')');
	});
}




function open_printad(url) {
	window.open(url, "printad", "toolbar=no, status=no, scrollbars=yes, resizable=yes, width=540, height=550");
}



/*
This prototype implements the array function indexOf for
browsers that dont support it (IE of course)

This prototype is provided by the Mozilla foundation and
is distributed under the MIT license.
http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
*/

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

    /* var image2=new Image()
	image2.src="/public/img/homepage_banner_bogo_XmasN_UK.jpg"
	image2.USEMAP="#home_img_map_bogo"
	var image1=new Image()
	image1.src="/public/img/homepage_banner_bargainN_UK.jpg"
	image1.USEMAP="#home_img_map_truevalue"
	var image3=new Image()
       image3.src="/public/img/homepage_banner_truevalueN_UK.jpg"
    */

       var image1=new Image()
       var site_bimg1;
       image1.src="/public/img/"+site_bimg1;
	var image2=new Image()
	var site_bimg2;
       image2.src="/public/img/"+site_bimg2;
       var image3=new Image()
       var site_bimg3;
       image3.src="/public/img/"+site_bimg3;



    var Stop_Img; 
    var step=1;
    var asdf ;
	function changeimage(towhat,url,tdid){
        Stop_Img = "Stop";

		if (document.images){
			Stop_Img = "Stop";
			document.images.targetimage.src=towhat.src
		    gotolink=url
            if(tdid=='1') {Change_TD1_Img(1); Change_TD2_Img(2); Change_TD3_Img(2); }
            else if(tdid=='2') {Change_TD2_Img(1); Change_TD1_Img(2); Change_TD3_Img(2);}
			else if(tdid=='3') {Change_TD3_Img(1); Change_TD1_Img(2); Change_TD2_Img(2);}
		}
	}
	function warp(){
		window.location=gotolink
	}


function Change_TD1_Img(a){

	if(a=='1') { 
document.getElementById("test1").style.background='url(/public/css/home_images/callindia_on.jpg)';
document.getElementById('test1').className='fonttd1'; 
document.getElementById('t1').className='fonttd1'; 
document.getElementById("bogo").style.display = "";
document.getElementById("truevalue").style.display = 'none';
document.getElementById("onecent").style.display = 'none';
    }else{
document.getElementById("test1").style.background='url(public/css/home_images/callindia_off.jpg)';	
document.getElementById('test1').className='fonttd2'; 
document.getElementById('t1').className='fonttd2'; 
	}
}

function Change_TD2_Img(a){

	if(a=='1') {
document.getElementById("test2").style.background='url(/public/css/home_images/true1_on.jpg)';
document.getElementById('test2').className='fonttd1'; 
document.getElementById('t2').className='fonttd1';
document.getElementById("bogo").style.display = "none";
document.getElementById("truevalue").style.display = "";
document.getElementById("onecent").style.display = "none";

    }else{
document.getElementById("test2").style.background='url(/public/css/home_images/true1_off.jpg)';	
document.getElementById('test2').className='fonttd2'; 
document.getElementById('t2').className='fonttd2';
	}
}


function Change_TD3_Img(a){

	if(a=='1') {
document.getElementById("test3").style.background='url(/public/css/home_images/truevalue_on.jpg)';
document.getElementById('test3').className='fonttd1'; 
document.getElementById('t3').className='fonttd1';
document.getElementById("bogo").style.display = "none";
document.getElementById("truevalue").style.display = "none";
document.getElementById("onecent").style.display = "";

    }else{
document.getElementById("test3").style.background='url(/public/css/home_images/truevalue_off.jpg)';	
document.getElementById('test3').className='fonttd2'; 
document.getElementById('t3').className='fonttd2';
	}
}
function make_blank(){
     document.useremail.user_email_id.value ="";
}



	var myimages=new Array()
	var gotolink="#"

function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
	myimages[i]=new Image()
	myimages[i].src=preloadimages.arguments[i]
    }
}


//preloadimages("/public/img/homepage_banner_bargainN_UK.jpg","/public/img/homepage_banner_bogo_XmasN_UK.jpg","/public/img/homepage_banner_truevalueN_UK.jpg")

preloadimages('/public/img/'+site_bimg1,'/public/img/'+site_bimg2,'/public/img/'+site_bimg3)

function hideshow() {
	sd = window.open('/public/css/home_images/pop.html','NewWin','toolbar=no,status=no,width=740,height=430,toolbar=yes,resizable=no,scrollbars=no')
	sd.moveTo(10,10);
}

if(location.href=='http://'+document.domain+'/' || location.href=='http://'+document.domain+'/home' || location.href=='https://'+document.domain+'/' || location.href=='https://'+document.domain+'/home'){
/*
function slideit(){

    if(Stop_Img != "Stop") {

		//if browser does not support the image object, exit.
		if (!document.images) { return }
		else{
			document.images.targetimage.src=eval("image"+step+".src")
			if(step=='1') {Change_TD1_Img(1); Change_TD2_Img(2); Change_TD3_Img(2);}
			else if(step=='2') {Change_TD2_Img(1); Change_TD1_Img(2); Change_TD3_Img(2); }
			else if(step=='3') {Change_TD3_Img(1); Change_TD1_Img(2); Change_TD2_Img(2);}
		}
		if (step<3)
		step++
		else
		step=1
		//call function "slideit()" every 1.5 seconds
		if(Stop_Img!="Stop"){ setTimeout("slideit()",5000) }
    
	} 

}
*/
}
