// @2009.9.9 cargosmart homepage promotion usage
var displayNumber = 0;
function caseItemObject(id, url, name, value, img){
	this.url = url;
	this.name = name;
	this.value = value;
	this.img = img; 
}
var caseItemSC = new Array();
caseItemSC[1] = new caseItemObject("Apex","apex.htm","- Kevin Bulger, Vice President of Operations, <br> &nbsp;&nbsp;Apex Maritime","CargoSmart Private Label Sailing Schedule enabled us to enhance our Web site with minimal in-house effort and to provide value-added services to our customers.", "cust_apex.gif");
caseItemSC[2] = new caseItemObject("Tronex", "tronex.htm", "- Eric Meichsner, Director of Operations, Tronex International, Inc.",        "CargoSmart's ISF solution is an ideal self-filing solution for us. It gives us control over our filing process, is easy to use, and saves us money on filing costs.", "cust_tronex.gif");
caseItemSC[3] = new caseItemObject("Herbalife","herbalife.htm","- Gina Glover, Manager Export Operations and Compliance, Herbalife","CargoSmart helps us streamline our export management processes. In fact, the turnaround time, from making a bill of lading approval or correction to having it in hand, often happens in less than an hour.", "cust_herbalife.gif");
caseItemSC[4] = new caseItemObject("Transco Shipping","transco.htm","- Lee Liu, Sales and Marketing Manager,<br/> &nbsp;&nbsp;Transco Shipping","We are extremely satisfied with CargoSmart's ISF solution&nbsp;and&nbsp;excellent&nbsp;customer&nbsp;service.&nbsp;CargoSmart's solution is easy-to-use and allows us to offer ISF filing as a value-added service for our customers.", "cust_transco.jpg");
caseItemSC[5] = new caseItemObject("OfficeMax","officemax.htm","- Regina Cox, OPS &ndash; Import Analyst, OfficeMax",          "With CargoSmart's customized Reports, we automate our reporting process, save our logistics team time, have greater shipment visibility, and spend more time on planning for our just-in-time deliveries.", "cust_officemax.gif");
caseItemSC[6] = new caseItemObject("Solutia","solutia.htm","- Gary Greenhill, Strategic Sourcing Manager, Solutia","We subscribe to exception alert e-mails from CargoSmart for the latest shipment changes so that we can let our customers know about them as they occur and so that we have as much time as possible to work on alternate plans.", "cust_solutia.gif");
caseItemSC[7] = new caseItemObject("Maritime Logistics und Operations GmbH (MLO)", "mlo.htm","- Susanne Woidt, Forwarding Department, MLO",            "The daily, customized sailing schedules that we receive are a tremendously effective planning tool for our organization in Germany and Russia and help streamline communications with our carriers, suppliers, and consignees." , "cust_mlo.gif");
caseItemSC[8] = new caseItemObject("Wathne", "wathne.htm","- Kesara Nowik, Import Manager, Traffic Department, Wathne ",            "CargoSmart saves us from making over 20 phone calls a week to our carriers to determine the latest detailed shipment status information that we need to share with our supply chain partners for just-in-time retail deliveries." , "cust_wathne.jpg");

function writeStory(langVersion, first) {
	if(displayNumber==8) displayNumber=0;
	displayNumber++;	
	showStory(langVersion, displayNumber);	

}
function showStory(langVersion, displayNumber) {
 var read = langVersion == "sc" ? "&#32454;&#38405;&#25104;&#21151;&#26696;&#20363;" : "Read the full success story"; 
 var story = caseItemSC[displayNumber]; 
 $('#customer_div').empty().append('<table width="100%" border="0" cellpadding="0" cellspacing="3">'+    
                    '<tr><td align="center" class="imgPadding">'+'<a href="customers/' + story.url + '">'+
       '<img src="../inc/images/' + story.img + '" border="0"></a></td></tr>'+                    
                    '<tr><td valign="top">"' + story.value + '"</td></tr>'+       
                    '<tr><td valign="top" class="top4padding">' + story.name + '</td></tr>'+      
                    '<tr><td align="right" valign="top" class="top4Padding">'+
     '<a href="customers/' + story.url + '">' + read + '</a></td></tr></table>'); 
}
/*homepage slide show */
function showDiv(src) {	$('#this_pic').attr('src',src).fadeIn(600, function(){$("#this_pic").data("tranCompleted",true);})}
function displayDiv(picType, langType) {
	var value;
	if (langType == 'sc') {
		$('#this_pic').attr('src').split(/images\//)[1].split(".")[0].split("_")[1];
	} else {
		$('#this_pic').attr('src').split(/images\//)[1].split(".")[0];	
	}				
	if(value == picType) return;
	$(".btn_table").each(function(){
	  var type;
	  if (langType == 'sc') {
		  type = $(this).attr('id').split("_")[2];
		  if (type == picType) {
			  $("#sc_btn_" + type).fadeIn(100);									  
		  } else {
			  $("#sc_btn_" + type).hide();	
		  }
	  } else {
		  type = $(this).attr('id').split("_")[1];
		  if (type == picType) {
			  $("#btn_" + type).fadeIn(100);									  
		  } else {
			  $("#btn_" + type).hide();	
		  }
	  }		  
	})
	currentType = picType;	
	if (langType == 'sc') {
		$('#this_pic').data("tranCompleted", false).attr('src','../inc/images/sc_'+picType+'.jpg').fadeIn(600, function(){$("#this_pic").data("tranCompleted",true);});		
	} else {
		$('#this_pic').data("tranCompleted", false).attr('src','../inc/images/'+picType+'.jpg').fadeIn(600, function(){$("#this_pic").data("tranCompleted",true);});	
	}
	if ($.browser.version == 6.0) {
		resetStyle_ie6(langType);
	} else {
		resetStyle(langType);	
	}	
}
function resetStyle(langType) {
	$("#pic_list div").each(function(){
		var current = $(this);
		var styleClass;
		if (langType == 'sc') {
			styleClass = current.attr('class').split("_")[1];
			if (styleClass == currentType) {
				current.removeClass().addClass("sc_" + styleClass+"_over");
			} else {
				current.removeClass().addClass("sc_" + styleClass);
			}
		} else {
			styleClass = current.attr('class').split("_")[0];
			if (styleClass == currentType) {
				current.removeClass().addClass(styleClass+"_over");
			} else {
				current.removeClass().addClass(styleClass);
			}
		}	
	});
}
function resetStyle_ie6(langType) {
	$("#pic_list div").each(function(){
		var current = $(this);
		var styleClass;
		if (langType == 'sc') {
			styleClass = current.attr('class').split("_")[1];
			if (styleClass == currentType) {
				current.removeClass().addClass("sc_" + styleClass+"_over_6");
			} else {
				current.removeClass().addClass("sc_" + styleClass + "_6");
			}
		} else {
			styleClass = current.attr('class').split("_")[0];
			if (styleClass == currentType) {
				current.removeClass().addClass(styleClass+"_over_6");
			} else {
				current.removeClass().addClass(styleClass + "_6");
			}
		}	
	});
}
function changeStyle(value, langType) {
	if (langType == 'sc') {
		if ($.browser.version == 6.0) {
			$("#pic_list div").each(function(){			 
				 var current = $(this);
				 var styleClass= current.attr("class").split("_")[1];
				 if (styleClass == value) {
					current.removeClass().addClass("sc_" + styleClass + "_over_6");
				 } else {
					current.removeClass().addClass("sc_" + styleClass + "_6");
				 }			 			 
			});
		} else {
			$("#pic_list div").each(function(){			 
				 var current = $(this);
				 var styleClass= current.attr("class").split("_")[1];
				 if (styleClass == value) {
					current.removeClass().addClass("sc_" + styleClass + "_over");
				 } else {
					current.removeClass().addClass("sc_" + styleClass);
				 }			 			 
			});
		}
	} else {
		if ($.browser.version == 6.0) {
			$("#pic_list div").each(function(){			 
				 var current = $(this);
				 var styleClass= current.attr("class").split("_")[0];
				 if (styleClass == value) {
					current.removeClass().addClass(styleClass + "_over_6");
				 } else {
					current.removeClass().addClass(styleClass + "_6");
				 }			 			 
			});
		} else {
			$("#pic_list div").each(function(){			 
				 var current = $(this);
				 var styleClass= current.attr("class").split("_")[0];
				 if (styleClass == value) {
					current.removeClass().addClass(styleClass + "_over");
				 } else {
					current.removeClass().addClass(styleClass);
				 }			 			 
			});
		}
	}
}

/*function to display splash according to current visits, and add visits after display*/
var CookieSplash = {
	getCookies:function(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); // remove the space in the header
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
  },
	setCookies: function(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 to display splash according to current visits, and add visits after display*/
function displaySplash(lang){	
	var visits=parseInt(CookieSplash.getCookies('num')) + 1;
	var temp = (visits-1)%3;
	var stylePostfixforIE6 = "";
	if ($.browser.version == 6.0) {stylePostfixforIE6 = "_6";}
	if(lang == "en"){
		switch(temp){
			case 0: $("#this_pic").attr("src","../inc/images/eei.jpg"); //update display splash pic
					$("#btn_isf").hide(); //update display button table
					$("#btn_eei").show();
					$("#btn_avr").hide();
					$("#isf").removeClass().addClass("isf"+stylePostfixforIE6); //update thumbnail class
					$("#eei").removeClass().addClass("eei_over"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("avr"+stylePostfixforIE6);
					break;
			case 1:$("#this_pic").attr("src","../inc/images/isf.jpg");
					$("#btn_isf").show();
					$("#btn_eei").hide();
					$("#btn_avr").hide();
					$("#isf").removeClass().addClass("isf_over"+stylePostfixforIE6); 
					$("#eei").removeClass().addClass("eei"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("avr"+stylePostfixforIE6);
					break;
			case 2: $("#this_pic").attr("src","../inc/images/avr.jpg"); 
					$("#btn_isf").hide();
					$("#btn_eei").hide();
					$("#btn_avr").show();
					$("#isf").removeClass().addClass("isf"+stylePostfixforIE6);
					$("#eei").removeClass().addClass("eei"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("avr_over"+stylePostfixforIE6);
					break;
		}	
	}
	else if(lang == "sc"){
		switch(temp){
			case 2: $("#this_pic").attr("src","../inc/images/sc_avr.jpg"); 
					$("#sc_btn_ssm").hide(); 
					$("#sc_btn_isf").hide();
					$("#sc_btn_avr").show();
					$("#ssm").removeClass().addClass("sc_ssm"+stylePostfixforIE6); 
					$("#isf").removeClass().addClass("sc_isf"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("sc_avr_over"+stylePostfixforIE6);
					break;
			case 1:$("#this_pic").attr("src","../inc/images/sc_ssm.jpg");
					$("#sc_btn_ssm").show();
					$("#sc_btn_isf").hide();
					$("#sc_btn_avr").hide();
					$("#ssm").removeClass().addClass("sc_ssm_over"+stylePostfixforIE6); 
					$("#isf").removeClass().addClass("sc_isf"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("sc_avr"+stylePostfixforIE6);
					break;
			case 0: $("#this_pic").attr("src","../inc/images/sc_isf.jpg"); 
					$("#sc_btn_ssm").hide();
					$("#sc_btn_isf").show();
					$("#sc_btn_avr").hide();
					$("#ssm").removeClass().addClass("sc_ssm"+stylePostfixforIE6);
					$("#isf").removeClass().addClass("sc_isf_over"+stylePostfixforIE6);
					$("#avr").removeClass().addClass("sc_avr"+stylePostfixforIE6);
					break;
		}	
	}
	
    CookieSplash.setCookies('num', visits, 365);
}   

function detectVisit(lang){
	if(!CookieSplash.getCookies('num')){		
		CookieSplash.setCookies('num', 1, 365);		
	}
	displaySplash(lang);
}

function reinitIframe(iframeid){
	var iframe = document.getElementById(iframeid);
	try{
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height =  height;
	}catch (ex){}
}