// JavaScript Document
var baseurl = "http://"+window.location.hostname+"/index.php/";

$(document).ready(function(){
	// Navigation JS
	$("a.mainNavALink").mouseover(function() {
		$(this).next('div.subNavHolder').stop().show();
	});
	$("a.mainNavALink").mouseout(function() {
		$(this).next('div.subNavHolder').stop().hide();
	});
	$("div.subNavHolder").mouseover(function() {
		$(this).stop().show();
		$(this).prev("a.mainNavALink").stop().addClass('hoverMain');
	});
	$("div.subNavHolder").mouseout(function() {
		$(this).stop().hide();
		$(this).prev("a.mainNavALink").stop().removeClass('hoverMain');
	});
	
	$("div.servicesNavRightContent").mouseover(function() {
		$(this).addClass('backgroundChangeHover2');
	});
	$("div.servicesNavRightContent").mouseout(function() {
		$(this).removeClass('backgroundChangeHover2');
	});
	
	
	$("div.solutionsOurApproachHolder table tr td").mouseover(function() {
		$(this).stop().addClass('backgroundChangeHover');
	});
	$("div.solutionsOurApproachHolder table tr td").mouseout(function() {
		$(this).stop().removeClass('backgroundChangeHover');
	});
	
	$('input.onSubmitContactUsForm').click(function() {
		var title = "";
		if($("input#Mr").is(":checked")){
			title = "Mr";
		}
		else if($("input#Ms").is(":checked")){
			title = "Ms";
		}
		else if($("input#Mrs").is(":checked")){
			title = "Mrs";
		}
		
		var fname = $("input#fname").val();
		var lname = $("input#lname").val();
		var accountno = $("input#accountno").val();
		var phoneno = $("input#phoneno").val();
		var email = $("input#email").val();
		var message = $("textarea#message").val();
		
		$('p.contactUsLoadingP').show();
		
		$.ajax({
			type: "POST",
			url: baseurl+"contact_us/validate_contact/",
			data: "fname="+fname+"&lname="+lname+"&accountno="+accountno+"&phoneno="+phoneno+"&email="+email+"&message="+message+"&title="+title,
			async:false,
			success: function(msg){
				$('p.contactUsLoadingP').hide();
				$("div#popup_opacity").hide();
				$("div.alertHolder").show();
				$("div#popup_block").fadeIn(300, function () { });
				$("div.lightwindowAlertError p.message").html(msg);	
				
				if(msg.search('Please try again later') || msg.search('<font color="#FF0000">')){
					msg = '';
				}
				else{
					$('input#clearcontactus').trigger('click');
				}
			}
		});	
	});	
	
	$('div.btnSubscriberHolder a').click(function() {
		$("div.alertHolder").hide();
		$("div#popup_block").fadeOut(300, function () { });
	});	
	
	$('img.closePopupImage').click(function() {
		$("div.alertHolder").hide();
		$("div#popup_block").fadeOut(300, function () { });
	});
});

function show_copyright(){
	$("div#popup_opacity").show();
	$("div.copyrightMainOverlayHolder").show();
	$("div#popup_block").fadeIn(300, function () { });	
}

function close_copyright(){
	$("div#popup_block").fadeOut(300, function () { });	
	$("div.copyrightMainOverlayHolder").hide();
	$("div#popup_opacity").hide();
}

function show_disclaimer(){
	$("div#popup_opacity").show();
	$("div.disclaimerMainOverlayHolder").show();
	$("div#popup_block").fadeIn(300, function () { });	
}

function close_disclaimer(){
	$("div#popup_block").fadeOut(300, function () { });	
	$("div.disclaimerMainOverlayHolder").hide();
	$("div#popup_opacity").hide();
}

function show_livechat(){
	newwindow=window.open('http://psstrust.com/psstrustlivechat/main/client','name','height=800,width=600,,scrollbars=1,location=0,menubar=0,resizable=1');	
}

function searchFocus(){
	if(document.getElementById("search_text").value=="Search"){
		$("#search_text").val("");
	}
}
function searchBlur(){
	if(document.getElementById("search_text").value==""){
		$("#search_text").val("Search");
	}
}
