$(document).ready(function(){
	$("a#single_image").fancybox(); 
	$("a#inline").fancybox({ 'hideOnContentClick': false }); 
	$("a.overlay_group").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:275, frameWidth:550, 'hideOnContentClick':false }); 
	$("a#interactivemap").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:567, frameWidth:930, 'hideOnContentClick': false });
	$("a#internetmap").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:567, frameWidth:730, 'hideOnContentClick': false });
	$("a#read1").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read2").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read3").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read4").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read5").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read6").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read7").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	$("a#read8").fancybox({ 'overlayOpacity': .5, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, frameHeight:530, frameWidth:730, 'hideOnContentClick': true });
	

//	$("#tab_business").bind("click", function(e){
//	 	resetMainNavTabs();
//     	$('#tab_business').attr('class','on');
//     	$('#business_nav').show("slide", { direction: "down" }, 1000);
//		//$.post("/actions/ajax_set_tab.php", { type:"business"});
//    });
//    
//    $("#tab_personal").bind("click", function(e){
//	 	resetMainNavTabs();
//     	$('#tab_personal').attr('class','on');
//     	$('#personal_nav').show("slide", { direction: "down" }, 1000);
//		//$.post("/actions/ajax_set_tab.php", { type:"personal"});
//    });

    $(".print_screen").bind("click", function(e){
	 	window.print();
    });

    
//    var urlvars = getUrlVars();
//    if(urlvars["navtype"] == 'business') {
//    	setTabBusiness();
//    } else {
//    	setTabPersonal();
//    }
});

function setTabBusiness() {
	$('#tab_business').attr('class','on');
	$('#tab_personal').attr('class','off');
	$('#tab_mycellcom').attr('class','off');
}

function setTabPersonal() {
	$('#tab_personal').attr('class','on');
	$('#tab_business').attr('class','off');
	$('#tab_mycellcom').attr('class','off');
}

function setTabMyCellcom() {
	$('#tab_personal').attr('class','off');
	$('#tab_business').attr('class','off');
	$('#tab_mycellcom').attr('class','on');
	$('#personal_nav').hide();
	$('#business_nav').hide();
	$('#mycellcom_nav').show();
}

function resetMainNavTabs() {
	$('#tab_personal').attr('class','off');
	$('#tab_business').attr('class','off');
	$('#tab_mycellcom').attr('class','off');
	$('#personal_nav').hide();
	$('#business_nav').hide();
	$('#mycellcom_nav').hide();
	
}

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
}; 


function findLocation() {
	
	$("#locationhover").fadeToggle();
	// $('#locationhover').fadeIn('slow');
//		function benmen(eid) {
//			if (t) {
//				clearTimeout(t);
//			}
//			obj = document.getElementById(eid);
//			var curleft = 0;
//			var curtop = 0;
//			if(obj.offsetParent) {
//				do {
//					curleft += obj.offsetLeft;
//					curtop += obj.offsetTop;
//				} while (obj = obj.offsetParent);
//			}
//			if(navigator.userAgent.search("MSIE")!=-1) {
//				document.getElementById(eid + '_menu').style.left = curleft + "px";
//				document.getElementById(eid + '_menu').style.top = (curtop + 28) + "px";
//			} else {
//				document.getElementById(eid +'_menu').style.left = (curleft + 6) + "px";
//				document.getElementById(eid + '_menu').style.top = (curtop + 30) + "px";
//			}
//			Effect.Appear(eid + '_menu', {duration:.1});
//			return false;
//		}
//		function benmen_close() {
//			t=setTimeout('Effect.Fade("benmen_menu", {duration:.1})', 100);
//		}
	
}

var last_used_eid = 0;

toggleBox = function(eid, navid) {
	
	this.t = null;
	this.eid = eid;
	this.navid = navid;
	
	this.hit = function() {
		
		if(last_used_eid != 0 && last_used_eid != this.eid){
			$(last_used_eid).hide();
		}
		
		if (this.t) {
			clearTimeout(this.t);
		}
		
		if(this.navid) {
			$(this.navid).addClass("ddhover");
			$(this.navid).removeClass("dddefault");
		}
		last_used_eid = this.eid;
		$(this.eid).fadeIn("fast");

	}
	
	this.moff = function() {
		
		if(this.navid) {
			$(this.navid).addClass("dddefault");
			$(this.navid).removeClass("ddhover");
		}
		
		this.t=setTimeout('$("'+this.eid+'").hide();', 300);
	}
	
}

function findCallingPlans(type) {
	$("#callingplans_" + type).fadeToggle() 
	// $('#locationhover').fadeIn('slow');
	
}

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}


function hideLocation() {
	$('#locationhover').fadeOut('slow');
}

function open_chat() {
window.open("/chat/livehelp.php", "livechat", "menubar=no, scrollbars=no, status=no, titlebar=no, toolbar=no, width=520, height=450");
return false;
}

function loadByCat(opt){
	if(opt==0){window.location.href = '/admin/index.html';}
	if(opt>0){window.location.href = '/admin/index.html?cat=' + opt;}
	
}

function clearSearch() {
	if($('#search_field').val() == "Enter keywords to search the Cellcom site") {
		$('#search_field').val("");
	} 
}

function setSearch() {
	if($('#search_field').val() == "") {
		$('#search_field').val("Enter keywords to search the Cellcom site");
	}
}

function CreateBookmarkLink() {

	title = "Cellcom MP3s"; 
	url = "http://www.cellcom.com/music.html";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}

	
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false
	 }

	 return true					
}

function ValidateContactForm()
{
	var emailID=$('#email');
	var emailconf=$('#emailconf');
	var name=$('#name');
	var ssn=$('#ssn');
	
	if ((emailID.val()=="")||echeck(emailID.val())==false){
		alert("Please Enter A Valid Email")
		return false
	}
	
	if(emailconf.val() != emailID.val()){
		alert("Your email addresses do not match.  Please verify to continue.")
		return false
	}
	
	if(name.val() == ""){
		alert("Please enter a name to continue.")
		return false
	}
	
	if(ssn.val().length !=0)
	{
		if(ssn.val().length != 4)
		{
			alert("Please enter the last 4 digits of your SSN (Optional).");
			return false;
		}
	}
	
	return true;
 }

 function ValidateAgentForm(){
	var emailID=$('#t_email_address');
	var t_contact_person=$('#t_contact_person');
	
	if ((emailID.val()=="")||echeck(emailID.val())==false){
		alert("Please Enter A Valid Email")
		return false
	}
	
	if(t_contact_person.val() == ""){
		alert("Please enter a contact name to continue.")
		return false
	}
	
	return true;
 }
 
 function ValidateEmailSignup(){
	var emailID=$('#email');
	var t_contact_person=$('#fullname');
	
	if ((emailID.val()=="")||echeck(emailID.val())==false){
		alert("Please Enter A Valid Email")
		return false
	}
	
	if(t_contact_person.val() == ""){
		alert("Please enter a name to continue.")
		return false
	}
	
	return true;
 }
 
 function ValidateNewsForm(){
	var emailID=$('#t_email_address');
	var t_contact_person=$('#t_Name');
	
	if ((emailID.val()=="")||echeck(emailID.val())==false){
		alert("Please Enter A Valid Email")
		return false
	}
	
	if(t_contact_person.val() == ""){
		alert("Please enter a name to continue.")
		return false
	}
	
	return true;
 }