


function submitlink(linktype, url) {
var linkurl = window.location;
var title = document.title;
var wintitle = title.substr(title.indexOf(": ") + 2);

switch (linktype)
{
case "delicious":
  window.location = "http://del.icio.us/login/?url=" + linkurl + "&title=" + wintitle;
  break;
case "stumbleupon":
 window.location = "http://www.stumbleupon.com/submit?url=" + linkurl + "&title=" + wintitle;
   break;
case "sendtofriend":
 <!--   break; -->
case "forum":
	var gd = gdomain(linkurl);
  document.location.href = gd + url;
  break;
case "newsfeed":
  document.location.href = url;
  break;
case "twitter incontext":
  document.location.href = "http://twitter.com/home/?status=Reading this on InContext " + linkurl;
  break;
case "twitter perceptivesw":
  document.location.href = "http://twitter.com/home/?status=Reading this on Perceptive Software " + linkurl;
  break;
default:
  window.location = url;
}
}
function check_six(urlink) {
var url = urlink.match("http")
if (url == "http") {
return urlink;
} else {
return "";
}
}

function set_path(theForm, urlink) {
post_authenticate(theForm);
}

function set_path_URL(urlink) {
	window.location = "/customer-portal/index.psi?redirectto=" + escape(urlink);
	return true;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function SiteSearch(starting) {
	var qt=document.getElementById("SearchStr");
	var q=qt.value.replace(/ /gi, "+");
	strUrl =  "/search.nsf/search?open&q=" + q + "&site=All&start=0"; 
	window.location.href = strUrl
}

function CheckKey(e,form){
	var key=e.keyCode || e.which;
	if (key==13){
		return SiteSearch(0);
	}
}

function getResults(starting) {
	var qt=document.getElementById("SearchString");
	var q=qt.value.replace(/ /gi, "+");
	var start = "";
	if (starting !==""){
		start = "&start=" + starting;
	}
	
	var isite=document.getElementById("site");
	var site = isite.options[isite.selectedIndex].value 
	// uses baseurl that is set on the form itself
	strUrl = baseurl + "/search?open&q=" + q + "&site=" + site + start; 
//	makeHttpRequest(strUrl, "fillVHTML(", false);
	window.location.href = strUrl
}

function fillVHTML (result){
	var u = document.getElementById("results");
	u.innerHTML = result
}

function errorAlert(msgtext){
	var stat =  document.getElementById("status");
	 stat.innerHTML = msgtext;         
}

function openDBRelativeURL( url, target ){
 	//Check we have a target window;
//	alert(url)
 	target = (target==null) ? window : target;
 	//Work out the path of the database;
 	path = location.pathname.split('.nsf')[0] + '.nsf/';
 	target.location.href = path + url;
}

//open div 
function open(DivName) 
{
	var x=document.getElementById(DivName)
	 x.style.display = 'block'
}

//close div 
function close(DivName) 
{
	var x=document.getElementById(DivName)
	 x.style.display = 'none'
}
function submit_external(theForm) {
	theForm.action = theForm.post_salesforce.value; 
	theForm.submit();
}

function submit_domino(theForm) {
  server_value = gdomain(theForm); 
	if(theForm.name == "contactv2") {
	
  	if(theForm.post_salesforce.value != "") {
	theForm.action = theForm.post_salesforce.value; 
	theForm.submit();
	  }	
	ContactFormValidator(theForm); 
	theForm.action = server_value + "/contact.nsf/" + theForm.name + "?createdocument";
	theForm.submit();
	} else {
	theForm.action = server_value + "/contact.nsf/" + theForm.name + "?createdocument";
	theForm.submit();
	}
}
function submit_lead(theForm) {
  server_value = gdomain(theForm);
	theForm.action = server_value + "/contact.nsf/" + theForm.name + "?createdocument";
	theForm.submit();
}


function login(theForm) {
post_authenticate(theForm);
}

function post_authenticate(theForm) {
  server_value = gdomain(theForm);
	qstring = querySt("redirectto");

if (qstring == "" || qstring == null) {
document.getElementById("redirectto").value = "/clpf.nsf/psiloginform?readform";
}else {
	document.getElementById("redirectto").value = qstring;
}	
	theForm.action = server_value + "/names.nsf?login"
	theForm.submit();
	return true;
}

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}

//Get domain to post contact data to proper server (ie - Dev, UAT, Production)
function gdomain(theForm) {
var dtmp = document.domain;
var srv = "";
switch (dtmp)
{
//Production Domain
 case "www.perceptivesoftware.com":
                 return "http://calypso.perceptivesoftware.com";
                 break; 
default:
                 return "http://calypso.perceptivesoftware.com";
                 break;
}
}
// -->;

function runsearch(theForm) {
var domval = gdomain(theForm);
theForm.action = domval + "/search.nsf/search?openform"
alert(theForm.action);
SiteSearch('0');
theForm.submit();
}			

function commonTemplate(item) {
			return "<option value='" + item.Value + "'>" + item.Text + "</option>"; 
			};
function commoncheck(item) {
			return "<li><a href='" + item.Value + "'>" + item.Text + "</a></li>"; 
			};
			
function commonMatch(selectedValue) {
			return this.When == selectedValue; 
			};
			
/* 
Used to get the collection of CaseStudies for the inital 
launch of the page. Also used as the reset for the page
if All is reselected as the Industry
*/
function loaddept() {
	$(document).ready(function(){
	
  	var industry = encodeURIComponent($('#industry').val());
  
  	if($('#industry').val() == "All") {
    	$("#caselist").load("/includes/xsl/case-study-list.jsp?Include=Beginning li");
    	$("#caselist1").load("/includes/xsl/case-study-list.jsp?Include=End li");
    	$(".departmentselect").css({"display":"none"});
  	} else {
    	$("#department").load("/includes/xsl/department-list.jsp?Industry=" + industry + " option");
    	$("#caselist").load("/includes/xsl/case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/case-study-list.jsp?Include=End&Industry=" + industry + " li");
    	$(".departmentselect").css({"display":"block"});
  	}
	});
}

function loaddept_hp() {
	$(document).ready(function(){
	
  	var industry = encodeURIComponent($('#industry').val());
  
  	if($('#industry').val() == "All") {
    	$("#caselist").load("/includes/xsl/hp-case-study-list.jsp?Include=Beginning li");
    	$("#caselist1").load("/includes/xsl/hp-case-study-list.jsp?Include=End li");
    	$(".departmentselect").css({"display":"none"});
  	} else {
    	$("#department").load("/includes/xsl/department-list.jsp?Industry=" + industry + " option");
    	$("#caselist").load("/includes/xsl/hp-case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/hp-case-study-list.jsp?Include=End&Industry=" + industry + " li");
    	$(".departmentselect").css({"display":"block"});
  	}
	});
}

function loaddept_inform() {
	$(document).ready(function(){
	
  	var industry = encodeURIComponent($('#industry').val());
  
  	if($('#industry').val() == "All") {
    	$("#caselist").load("/includes/xsl/inform-case-study-list.jsp?Include=Beginning li");
    	$("#caselist1").load("/includes/xsl/inform-case-study-list.jsp?Include=End li");
    	$(".departmentselect").css({"display":"none"});
  	} else {
    	$("#department").load("/includes/xsl/department-list.jsp?Industry=" + industry + " option");
    	$("#caselist").load("/includes/xsl/inform-case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/inform-case-study-list.jsp?Include=End&Industry=" + industry + " li");
    	$(".departmentselect").css({"display":"block"});
  	}
	});
}
function loaddept_contactus() {
	$(document).ready(function(){
	
  	var industry = encodeURIComponent($('#Industry').val());
  
    	$("#Department").load("/includes/xsl/contactus-department-list.jsp?Industry=" + industry + " option");
    	$("#OrganizationalArea").load("/includes/xsl/contactus-department-list.jsp?Industry=" + industry + " option");
				});
}

/* 
Used to get the collection of CaseStudies based on Industry
and Department
*/
function loadlist() {
  $(document).ready(function(){
  	var industry = encodeURIComponent($('#industry').val());
  	var dept = encodeURIComponent($('#department').val());
  	industry.replace(/ /g, "%20");
  	dept.replace(/ /g, "%20");	
    $(".departmentselect").css({"display":"block"});	

if (dept != null && dept != "All") {
    	$("#caselist").load("/includes/xsl/case-study-list.jsp?Include=Beginning&Industry=" + industry + "&Department=" + dept + " li");
    	$("#caselist1").load("/includes/xsl/case-study-list.jsp?Include=End&Industry=" + industry + "&Department=" + dept + " li");
  	} else {
		
    	industry.replace(/ /g, "%20");
    	dept.replace(/ /g, "%20");
    	
     	$("#caselist").load("/includes/xsl/case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/case-study-list.jsp?Include=End&Industry=" + industry + " li");
  	}
	});
}

function loadlist_hp() {
  $(document).ready(function(){
  	var industry = encodeURIComponent($('#industry').val());
  	var dept = encodeURIComponent($('#department').val());
  	industry.replace(/ /g, "%20");
  	dept.replace(/ /g, "%20");	
    $(".departmentselect").css({"display":"block"});	

if (dept != null && dept != "All") {
    	$("#caselist").load("/includes/xsl/hp-case-study-list.jsp?Include=Beginning&Industry=" + industry + "&Department=" + dept + " li");
    	$("#caselist1").load("/includes/xsl/hp-case-study-list.jsp?Include=End&Industry=" + industry + "&Department=" + dept + " li");
  	} else {
		
    	industry.replace(/ /g, "%20");
    	dept.replace(/ /g, "%20");
    	
     	$("#caselist").load("/includes/xsl/hp-case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/hp-case-study-list.jsp?Include=End&Industry=" + industry + " li");
  	}
	});
}
function loadlist_inform() {
  $(document).ready(function(){
  	var industry = encodeURIComponent($('#industry').val());
  	var dept = encodeURIComponent($('#department').val());
  	industry.replace(/ /g, "%20");
  	dept.replace(/ /g, "%20");	
    $(".departmentselect").css({"display":"block"});	

if (dept != null && dept != "All") {
    	$("#caselist").load("/includes/xsl/inform-case-study-list.jsp?Include=Beginning&Industry=" + industry + "&Department=" + dept + " li");
    	$("#caselist1").load("/includes/xsl/inform-case-study-list.jsp?Include=End&Industry=" + industry + "&Department=" + dept + " li");
  	} else {
		
    	industry.replace(/ /g, "%20");
    	dept.replace(/ /g, "%20");
    	
     	$("#caselist").load("/includes/xsl/inform-case-study-list.jsp?Include=Beginning&Industry=" + industry + " li");
    	$("#caselist1").load("/includes/xsl/inform-case-study-list.jsp?Include=End&Industry=" + industry + " li");
  	}
	});
}
function geturl(url) {
var x = document.title.split(" - ");
if(x[1] == null) {
window.location = url;
} else {
window.location = url + "&NavHint=" + escape(x[1]);
}
}
function checkcountry()
{
$(document).ready(function() {
if ($('#Country').val() != "United States") {
$('#State_Province').val("");
$('#statesblock').hide('fast');
} else {
$('#statesblock').show('fast');
}
});
}

function hearus() {
$(document).ready(function() {
if ($('#LeadSourceMostRecent').val() != "Word of Mouth") {
$('#wordquestion').hide('fast');
} else {
$('#wordquestion').show('fast');
}

});
}

function hideother() {
$(document).ready(function() {
if ($('#othercheck:checked').val() != undefined) {
$('.otherdata').show('fast');
} else {
$('.otherdata').hide('fast');
$('#othertexterror').hide('fast');
}
});

}


