// @2009.9.9 cargosmart homepage promotion usage
// @2011.12.9 Add SC version specifically for SC page.Add promo number.
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(); //For SC language
caseItemSC[1] = new caseItemObject("Vanguard","../news/vanguard-logistics-services-implements-cargosmart-sailing-schedules.htm","- Haydn O&rsquo;Brien, &#32500;&#20339;&#29289;&#27969;&#30340;&#19996;&#20122;&#22320;&#21306;&#24635;&#35009;","&#36135;&#35759;&#36890;&#25552;&#20379;&#30340;&#33258;&#21160;&#21270;&#26381;&#21153;&#24110;&#21161;&#25105;&#20204;&#25552;&#39640;&#20844;&#21496;&#30340;&#19994;&#21153;&#25928;&#29575;&#65292;&#33410;&#30465;&#20102;&#25805;&#20316;&#22242;&#38431;&#25910;&#38598;&#12289;&#21457;&#24067;&#21644;&#26356;&#26032;&#33337;&#26399;&#25968;&#25454;&#30340;&#26102;&#38388;&#12290;", "cust_vanguard.jpg");
caseItemSC[2] = new caseItemObject("Hellmann","../news/hellmann-selects-cargosmart-private-label-sailing-schedule.htm","- Jens Pottschul, &#27721;&#23439;&#36135;&#36816;&#26377;&#38480;&#20844;&#21496;&#20122;&#27954;&#21306;&#28023;&#36816;&#21103;&#24635;&#35009;","&#25105;&#20204;&#37319;&#29992;&#36135;&#35759;&#36890;&#30340;&#23458;&#25143;&#19987;&#29992;&#33337;&#26399;&#34920;&#65292;&#20026;&#20844;&#21496;&#30340;&#19994;&#21153;&#30456;&#20851;&#32773;&#25552;&#20379;&#29616;&#26102;&#26368;&#20248;&#36136;&#30340;&#33337;&#26399;&#34920;&#25968;&#25454;&#12290;", "cust_hellmann.gif");
caseItemSC[3] = new caseItemObject("Apex","apex.htm","- Kevin Bulger, Apex Maritime&#30340;&#33829;&#36816;&#21103;&#24635;&#35009;","&#36135;&#35759;&#36890;&#23458;&#25143;&#19987;&#29992;&#33337;&#26399;&#34920;&#35753;&#25105;&#20204;&#20844;&#21496;&#21487;&#20197;&#29992;&#26368;&#23569;&#36164;&#28304;&#65292;&#20026;&#23458;&#25143;&#25552;&#20379;&#26368;&#22909;&#30340;&#22686;&#20540;&#26381;&#21153;&#65292;&#36798;&#21040;&#21152;&#24378;&#20844;&#21496;&#32593;&#31449;&#26381;&#21153;&#30340;&#25104;&#25928;&#12290;", "cust_apex.gif");
caseItemSC[4] = new caseItemObject("Tronex", "tronex.htm", "- Eric Meichsner, Director of Operations, <br> &nbsp;&nbsp;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[5] = new caseItemObject("Panalpina", "../news/press_25_jan_11.htm","- Jens Kalter, &#27867;&#20122;&#29677;&#25343;&#30340;&#32463;&#29702;",            "&#36890;&#36807;&#36830;&#25509;&#21040;&#36135;&#35759;&#36890;&#30340;&#22810;&#26041;&#25215;&#36816;&#20154;&#33337;&#26399;&#34920;&#65292;&#33021;&#26356;&#21152;&#23436;&#21892;&#21644;&#34917;&#20805;&#25105;&#20204;&#29616;&#26377;&#19968;&#27969;&#30340;IT&#31995;&#32479;&#25112;&#30053;&#65292;&#20174;&#32780;&#33021;&#20026;&#23458;&#25143;&#25552;&#20379;&#26368;&#20248;&#36136;&#30340;&#26381;&#21153;&#12290; " , "cust_panalpina.gif");
caseItemSC[6] = 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[7] = new caseItemObject("USI", "../news/press_14_jun_11.htm", "- Jacob Bech-Hansen, &#32654;&#36816;&#22269;&#38469;&#36135;&#36816;&#20195;&#29702;&#26377;&#38480;&#20844;&#21496;&#30340;&#21103;&#24635;&#35009;",        "&#25105;&#20204;&#25361;&#36873;&#20102;&#36135;&#35759;&#36890;&#30740;&#21457;&#30340;&#23574;&#31471;&#36135;&#20195;&#19994;&#21153;&#31649;&#29702;&#31995;&#32479;&#20197;&#25903;&#25345;&#25105;&#20204;&#39640;&#36895;&#30340;&#19994;&#21153;&#21457;&#23637;&#12290;&#36135;&#35759;&#36890;&#22312;&#33337;&#36816;&#19994;&#30340;&#19987;&#19994;&#24615;&#65292;&#32463;&#39564;&#21644;&#21487;&#38752;&#31243;&#24230;&#65292;&#37117;&#33021;&#20026;&#25105;&#21496;&#25552;&#20379;&#26368;&#20339;&#30340;&#26381;&#21153;&#21644;&#33337;&#36816;&#21487;&#35270;&#24615;&#32473;&#23458;&#25143;&#12290;", "cust_usi.gif");
caseItemSC[8] = 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[9] = new caseItemObject("Rhenus", "rhenus.htm", "- Hans-E. Mahncke, Managing Director, <br> &nbsp;&nbsp;Rhenus Logistics Asia-Pacific Ltd.",        "After integrating our freight management system with CargoSmart, we have streamlined our operations and saved 25 days a year managing multiple-carrier shipments.", "cust_rhenus.gif");
caseItemSC[10] = 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[11] = new caseItemObject("Transco Shipping","transco.htm","- Lee Liu, Transco Shipping&#30340;&#38144;&#21806;&#21644;&#33829;&#38144;&#32463;&#29702;","&#25105;&#20204;&#23545;&#36135;&#35759;&#36890;SF&#35299;&#20915;&#26041;&#26696;&#30340;&#25928;&#29992;&#21644;&#20854;&#19987;&#19994;&#30340;&#23458;&#25143;&#26381;&#21153;&#24863;&#21040;&#38750;&#24120;&#28385;&#24847;&#12290;&#36135;&#35759;&#36890;&#30340;&#35299;&#20915;&#26041;&#26696;&#26082;&#23481;&#26131;&#20351;&#29992;&#65292;&#20063;&#26041;&#20415;&#25105;&#20204;&#20026;&#23458;&#25143;&#25552;&#20379;ISF&#36825;&#39033;&#22686;&#20540;&#26381;&#21153;&#12290; ", "cust_transco.jpg");




var caseItemEN = new Array();// For EN language version
caseItemEN[1] = new caseItemObject("Vanguard","../news/vanguard-logistics-services-implements-cargosmart-sailing-schedules.htm","- Haydn O'Brien, Regional Managing Director,<br/> &nbsp;&nbsp;East Asia, Vanguard","CargoSmart's automated service improves our efficiency by saving our team a lot of time compiling, distributing, and updating sailing schedules.", "cust_vanguard.jpg");
caseItemEN[2] = new caseItemObject("Hellmann","../news/hellmann-selects-cargosmart-private-label-sailing-schedule.htm","- Jens Pottschul, Vice President, Seafreight Asia,<br/> &nbsp;&nbsp;Hellmann","We selected CargoSmart's solutions to deliver the best quality sailing schedule information available to our stakeholders.", "cust_hellmann.gif");
caseItemEN[3] = 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");
caseItemEN[4] = new caseItemObject("Tronex", "tronex.htm", "- Eric Meichsner, Director of Operations, <br> &nbsp;&nbsp;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");
caseItemEN[5] = new caseItemObject("Panalpina", "../news/press_25_jan_11.htm","- Jens Kalter, Global Standards & Governance Manager (FCL), Panalpina",            "Connecting to CargoSmart for multiple-carrier sailing schedules complements our strategy to leverage state-of-the-art IT systems to provide the highest level of quality service to our customers." , "cust_panalpina.gif");
caseItemEN[6] = 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");
caseItemEN[7] = new caseItemObject("USI", "../news/press_14_jun_11.htm", "- Jacob Bech-Hansen, Vice President, <br> &nbsp;&nbsp;Universal Shipping, Inc.",        "CargoSmart demonstrated the expertise, history, and credibility with steamship lines to offer best-in-class service and visibility to our customers.", "cust_usi.gif");
caseItemEN[8] = 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");
caseItemEN[9] = new caseItemObject("Rhenus", "rhenus.htm", "- Hans-E. Mahncke, Managing Director, <br> &nbsp;&nbsp;Rhenus Logistics Asia-Pacific Ltd.",        "After integrating our freight management system with CargoSmart, we have streamlined our operations and saved 25 days a year managing multiple-carrier shipments.", "cust_rhenus.gif");
caseItemEN[10] = 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");
caseItemEN[11] = 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");


function writeStory(langVersion, first) {
	if(displayNumber==11) 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 = langVersion == "sc" ? caseItemSC[displayNumber] :  caseItemEN[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/ccm.jpg"); 
			$("#btn_ccm").show();
			$("#btn_lsp").hide();
			$("#btn_sra").hide();
			$("#ccm").removeClass().addClass("ccm_over"+stylePostfixforIE6);
			$("#lsp").removeClass().addClass("lsp"+stylePostfixforIE6);
			$("#sra").removeClass().addClass("sra"+stylePostfixforIE6);
			break;
			case 1: $("#this_pic").attr("src","../inc/images/lsp.jpg"); //update display splash pic
					$("#btn_ccm").hide(); //update display button table
					$("#btn_lsp").show();
					$("#btn_sra").hide();
					$("#ccm").removeClass().addClass("ccm"+stylePostfixforIE6); //update thumbnail class
					$("#lsp").removeClass().addClass("lsp_over"+stylePostfixforIE6);
					$("#sra").removeClass().addClass("sra"+stylePostfixforIE6);
					break;
			case 2:$("#this_pic").attr("src","../inc/images/sra.jpg");
					$("#btn_ccm").hide();
					$("#btn_lsp").hide();
					$("#btn_sra").show();
					$("#ccm").removeClass().addClass("ccm"+stylePostfixforIE6); 
					$("#lsp").removeClass().addClass("lsp"+stylePostfixforIE6);
					$("#sra").removeClass().addClass("sra_over"+stylePostfixforIE6);
					break;
		}	
	}
	else if(lang == "sc"){
		switch(temp){
			case 1: $("#this_pic").attr("src","../inc/images/sc_sra.jpg"); 
					$("#sc_btn_ssm").hide(); 
					$("#sc_btn_ccm").hide();
					$("#sc_btn_sra").show();
					$("#ssm").removeClass().addClass("sc_ssm"+stylePostfixforIE6); 
					$("#ccm").removeClass().addClass("sc_ccm"+stylePostfixforIE6);
					$("#sra").removeClass().addClass("sc_sra_over"+stylePostfixforIE6);
					break;
			case 0:$("#this_pic").attr("src","../inc/images/sc_ssm.jpg");
					$("#sc_btn_ssm").show();
					$("#sc_btn_ccm").hide();
					$("#sc_btn_sra").hide();
					$("#ssm").removeClass().addClass("sc_ssm_over"+stylePostfixforIE6); 
					$("#ccm").removeClass().addClass("sc_ccm"+stylePostfixforIE6);
					$("#sra").removeClass().addClass("sc_sra"+stylePostfixforIE6);
					break;
			case 2: $("#this_pic").attr("src","../inc/images/sc_ccm.jpg"); 
					$("#sc_btn_ssm").hide();
					$("#sc_btn_ccm").show();
					$("#sc_btn_sra").hide();
					$("#ssm").removeClass().addClass("sc_ssm"+stylePostfixforIE6);
					$("#ccm").removeClass().addClass("sc_ccm_over"+stylePostfixforIE6);
					$("#sra").removeClass().addClass("sc_sra"+stylePostfixforIE6);
					break;
		}	
	}
	
    CookieSplash.setCookies('num', visits, 365);
} 

function displayPromo(lang){
	var visits=parseInt(CookieSplash.getCookies('num'));
	var t = visits%2;
	if(lang == "en"){
		switch(t){
			case 0:$("#promo_pic").attr("src","../inc/images/promotion_ssm20_en.png");
				   $("#promo_pic").parent().attr("href","http://itunes.apple.com/app/ssm20-lite/id395653863?mt=8");
				   break;
			case 1:$("#promo_pic").attr("src","../inc/images/promotion_cson_en.png");
				   $("#promo_pic").parent().attr("href","http://www.cargosmarton.com");	
				   break;
		}
	}
	else if(lang == "sc"){
		switch(t){
			case 0: $("#promo_pic").attr("src","../inc/images/promotion_ssm20_sc.png");
					$("#promo_pic").parent().attr("href","http://itunes.apple.com/app/ssm20-lite/id395653863?mt=8");
				    break;
			case 1: $("#promo_pic").attr("src","../inc/images/promotion_cson_sc.png");
					$("#promo_pic").parent().attr("href","http://www.cargosmarton.com/zh-hans/?auto=false");	
				    break;
		}
	}
	CookieSplash.setCookies('num', visits, 365);
}

function detectVisit(lang){
	if(!CookieSplash.getCookies('num')){		
		CookieSplash.setCookies('num', 1, 365);		
	}
	displaySplash(lang);
	displayPromo(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){}
}
