//JavaScriptDocument
jQuery(function(){
	jQuery('#nav').superfish({speed:50,delay: 800, animation: {height:'show'}});
});

$(function(){
	setTimeout(function() {
		$('#slideshow img:first').fadeIn(200);
		$('#slideshow').cycle();
	}, 200);
});

$(document).ready(function(){
	//$('.rcon p').eq(1).css({paddingTop:'0px'})

	$(".lcon").width($(".lcon img").width());
	$(".rcon").width(663-$(".lcon img").width()-10);
	
	var lht=$(".lcon").height();
	var rht=$(".rcon").height();
	
	if ($("#left").height() < 486) {$("#left").height(486)}
	
	if (lht>rht)
	{$(".rcon").height(lht);}
	else
	{$(".lcon").height(rht);}

	var l=$("#lcol").height();
	var r=$("#rcol").height();
	if (r>l)
	{$("#lcol").height(r);}
	else
	{$("#rcol").height(l);$("#right").height(l);}
	
	
	//case study page begin
	$(".ptop > img").wrap("<div class=\"logo\"></div>");
	$(".ptop > .logo").css("display","none").appendTo("body");
	var strText;
	strText=$.trim($(".ptop").text());
	$(".ptop").empty();
	$(".logo").appendTo(".ptop").css("display","block");
	$(".ptop").append("<div class=\"dv\"></div>");
	$(".ptop > .dv").text(strText);
	
	
	$(".ptop .dv").width(670-15-$(".logo img").width());

	if ($(".logo").height()>$(".ptop .dv").height())
	{$(".ptop .dv").css("padding-top",($(".logo").height()-$(".ptop .dv").height())/2);$(".ptop").height($(".logo").height());}
	else
	{$(".logo").height($(".ptop .dv").height());$(".ptop").height($(".ptop .dv").height());$(".logo img").css("margin-top",($(".logo").height()-$(".logo img").height())/2);}
		
	$("#pwrap ul").prev("#pwrap p").css("margin-bottom","0");
	
	if ($(".pcon .v1").height()>$(".pcon .v2").height() && $(".pcon .v1").height()>$(".pcon .norbor").height())
	{$(".pcon").height($(".pcon .v1").height());$(".pcon .v2").height($(".pcon .v1").height());$(".pcon .norbor").height($(".pcon .v1").height());}
	else if ($(".pcon .v2").height()>$(".pcon .v1").height() && $(".pcon .v2").height()>$(".pcon .norbor").height())
	{$(".pcon").height($(".pcon .v2").height());$(".pcon .v1").height($(".pcon .v2").height());$(".pcon .norbor").height($(".pcon .v2").height());}
	else
	{$(".pcon").height($(".pcon .norbor").height());$(".pcon .v1").height($(".pcon .norbor").height());$(".pcon .v2").height($(".pcon .norbor").height());}
	
	//case study page end
});



$(document).ready(function(){
	$("#slideshow a").addClass("popup");

	var curLocation;
	curLocation=window.location.href;
	if (curLocation.indexOf("client-list.html")>0 || curLocation.indexOf("/?pageid=15")>0)
	{
		
		$(".rcon a").each(function(){
			if (!$(this).hasClass("popup"))
			{$(this).addClass("popup");}
		});
	}

	$("a.popup").each(function(){
		
		var str;
		str=$(this).attr("href").toLowerCase();
		str=str.substring(str.indexOf("pageid=")+7);
		$(this).removeAttr("target");
		$(this).removeAttr("onclick");
		str="javascript:makeWindow('/popup.asp?pageid="+str+"',720,600);";
		$(this).attr("href",""+str+"");
	});

	$("img[src='/images/more.gif']").not($("#rcol *")).not($("a.nopopup img")).each(function(){
			var str;
			str=$(this).parent().attr("href").toLowerCase();
			//if (str.indexOf("pageid=")>-1 && str.indexOf("item.asp")<0)
			if (str.indexOf("pageid=")>-1)
			{
				$(this).parent().removeAttr("target");
				$(this).parent().removeAttr("onclick");
				str=str.substring(str.indexOf("pageid=")+7);
				str="javascript:makeWindow('/popup.asp?pageid="+str+"',720,600);";
				$(this).parent().attr("href",""+str+"");
			}
			else
			{
				$(this).parent().removeAttr("target");
				$(this).parent().removeAttr("onclick");
				str="javascript:makeWindow('/popup.asp?url="+str+"',720,600);";
				$(this).parent().attr("href",""+str+"");
			}
		});
	});


function makeWindow(theLoc,theWidth,theHeight){
	win=window.open(theLoc,"NewWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight);
	if(win.opener==null) win.opener=window;
	win.opener.name="opener";
}

function killWindow(){win=window.close();}

function showElement(id) {
	var status = document.getElementById(id).style.display;
	if (status == "block") {
		document.getElementById(id).style.display="none";
	} else {
		document.getElementById(id).style.display="block";
	}
}


function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_required(first_name,"Please make sure that you have entered your full name")==false)
  {first_name.focus();return false}
  
if (validate_required(last_name,"Please make sure that you have entered your full name")==false)
  {last_name.focus();return false}
  
if (validate_required(company,"Please make sure that you have entered your company name")==false)
  {company.focus();return false}  

if (validate_email(email,"Please make sure that you have entered a valid e-mail address")==false)
  {email.focus();return false}
  
if (validate_required(phone,"Please make sure that you have entered your phone number")==false)
  {phone.focus();return false}    
}
}

function killErrors(){
	return true;
}
window.onerror = killErrors;
