// JavaScript Document

function changeDept (where) {
		document.location.href = where;
}

function deptContactInfo (which, args) {
	
	var D = new Date();
	var DT = 2 * D.getTimezoneOffset() - (new Date(2004, 0)).getTimezoneOffset() - (new Date(2004, 6)).getTimezoneOffset();
	var closingTime
	
	//supposed to be either 0 or 60 for DST or not
	//document.write(Math.abs(DT)); 
	//this script is not working the way it's supposed to besides its running  on the client side which is wrong  this page is scheduled for redesign before daylight savings time resumes so the friday closing time was hard coded
	if (Math.abs(DT) == "60" ){
		closingTime = "1:00pm";
	}else{
		closingTime = "1:00pm"
	}	
	//----------------------------//

	// select the right information for each department and put it into an array, within an array

	/* This tests if in iFrame or not. */
	noContainer = document.location.toString().search('noContainer');
	if ( noContainer > 1 )	{	
		holidayschedule = "";
	} else {
		holidayschedule = "<a href='/find/HelpCenter/HoursOfOperation.jsp'>Holiday Schedule</a>";
	}
	/* End test */
	
	showform = true;
	foreignnumber = "<a href='home?O=helpcenter&A=getpage&Q=contactForm.jsp&destination=foreign'>Foreign Customers Line</a>";
	custemail = "<a href='mailto:sac@bhphotovideo.com'>Email Customer Service</a>";
	veriemail = "<a href='mailto:cobranca@bhphotovideo.com'>Email Verification</a>";
	liveHelp = "<a href='"+ args['liveChatHref'] +"' onclick=\"window.open(this.href,this.target,'height=350,width=650');\" target=\"livechat\" >Live Chat</a>";
	
	quickdial = "<a href='/find/HelpCenter/QuickDial.jsp'>click here</a>";
	
	contactInfo = new Array();
	
	switch(which)	
	{	
		
	case "sales":
		
		contactInfo["title"] = "Sales Department";
		
		salesContact = new Array ()
		salesContact[0] = "<b>By Phone</b>";
		salesContact[1] = "Phone: 	800.606.6969 or 212.444.6615";
		salesContact[2] = "Quick-Dial: 	"+quickdial;
		salesContact[3] = "Fax: 	800.947.7008 or 212.239.7770";
		salesContact[4] = foreignnumber;
/*		salesContact["title"] = "By Phone";
		salesContact[0] = "Phone: 	800.606.6969 or 212.444.6615";
		salesContact[1] = "Quick-Dial: 	"+quickdial;
		salesContact[2] = "Fax: 	800.947.7008 or 212.239.7770";
		salesContact[3] = foreignnumber;	*/	

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		hoursContact[1] = "Sunday: 	10:00AM - 5:00PM";
		hoursContact[2] = "Mon-Thu: 	9:00AM � 7:00PM";
		hoursContact[3] = "Friday: 	9:00am � " + closingTime;
		hoursContact[4] = holidayschedule;
		
		contactInfo[1] = salesContact;
		contactInfo[2] = hoursContact;
		
	break;    
	case "LiveHelp":
	
		$("#formHolder").remove();
		showform = false;
	
	
		liveContact = new Array ()
		liveContact[0] = "Chat with a professional sales representative, for product help and advice. "+liveHelp;
		
		contactInfo[1] = liveContact;
	
	break;
	case "status":
	
		contactInfo["title"] = "Customer Service Department";
		
		customerContact = new Array ()
		customerContact[0] = "<b>By Phone</b>";
		//customerContact["title"] = "By Phone";
		customerContact[1] = "Phone: 	800.221.5743 or 212.239.7765";
		customerContact[2] = "Fax: 	212-502-9426 or 866-521-7375";

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		//hoursContact["title"] = "Hours of Operation";		
		hoursContact[1] = "Sunday: 	10:00AM - 5:00PM";
		hoursContact[2] = "Mon-Thu: 	9:00AM - 6:00PM";
		hoursContact[3] = "Friday: 	9:00AM � " + closingTime;
		hoursContact[4] = holidayschedule;
		
		contactInfo[1] = customerContact;
		contactInfo[2] = hoursContact;
		
	break;
	case "verification":
		
		contactInfo["title"] = "Verification Department";
		
		verificationContact = new Array ()
		//verificationContact["title"] = "By Phone";
		//verificationContact[0] = "Phone: 	800.622.6265";

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		hoursContact[1] = "Sunday: 	10:00AM - 5:00PM";
		hoursContact[2] = "Mon-Thu: 	9:00AM � 7:00PM";
		hoursContact[3] = "Friday:	9:00AM � " + closingTime;
		
		contactInfo[1] = verificationContact;
		contactInfo[2] = hoursContact;
		
	break;
	case "used":

		contactInfo["title"] = "Used Department";
		
		usedContact = new Array ()
		usedContact[0] = "<b>By Phone</b>";
		usedContact[1] = "Phone: 800.606.6969 ext. 2700";
		usedContact[2] = "Fax: 	800.520.5444";
		
		contactInfo[1] = usedContact;
		
	break;
	case "corporatesales":
		
		contactInfo["title"] = "Corporate Sales Department";
		
		corpContact = new Array ()
		corpContact[0] = "<b>By Phone</b>";
		corpContact[1] = "Phone: 	800-947-9962";
		corpContact[2] = "Fax: 	212.239.7512";

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		hoursContact[1] = "Mon-Thu: 	9:00AM � 6:00PM";
		hoursContact[2] = "Fri: 	9:00AM � " + closingTime;
		hoursContact[3] = holidayschedule;
		
		contactInfo[1] = corpContact;
		contactInfo[2] = hoursContact;
		
	break;
	case "biddept":
	
		contactInfo["title"] = "Government/Education Department";
		
		govContact = new Array ()
		govContact[0] = "<b>By Phone</b>";
		govContact[1] = "Phone: 	800.947.8003 or 212-239-7503";
		govContact[2] = "<br/>Fax: 	<br/> Price Request: 800.743.0895 or 212.239.7509 <br/> PO's: 800.851.5292 or 212.239.7759";
		
		contactInfo[1] = govContact;
		
	break;
	case "india":
	
		$("#formHolder").remove();
		showform = false;
		
		contactInfo["title"] = "India Liaison Office";
		
		indiaAddress = new Array ()
		indiaAddress[0] = "<b>India Liaison Office Address</b>";
		indiaAddress[1] = "B&H Photo Video, India";
		indiaAddress[2] = "# 304, Gera Chambers,";
		indiaAddress[3] = "Off. Boat Club Road, Pune - 411001";
		indiaAddress[4] = "Maharashtra India";
		
		indiaContact = new Array ()
		indiaContact[0] = "<b>By Phone</b>";
		indiaContact[1] = "Toll Free from India: 	1.800.22.8008";
		indiaContact[2] = "Direct Line: 	020.30521900";
		indiaContact[3] = "Fax: 	1.800.22.8008";

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		hoursContact[1] = "Monday-Friday 	10:00AM - 6:00PM";
		
		contactInfo[1] = indiaAddress;
		contactInfo[2] = indiaContact;
		contactInfo[3] = hoursContact;

	break;
	case "vendas":
	
		contactInfo["title"] = "Portuguese Department";
		
		brazilPhone = new Array ()
		brazilPhone[0] = "<b>Portuguese Speaking Customers</b> <br/> (calling from Brazil)";
		brazilPhone[1] = "Phone: 	0800.891.5877";
		brazilPhone[2] = "Fax: 	0800.891.0320";
		
		usPhone = new Array ()
		usPhone[0] = "<b>Portuguese Speaking Customers</b> <br/> (calling from within the USA and Canada)";
		usPhone[1] = "Phone: 	866-729-8136 or 212-444-5005";
		usPhone[2] = "Fax: 	866-729-8141 or 212-239-7742";
		usPhone[3] = custemail;
		usPhone[4] = veriemail;

		hoursContact = new Array ()
		hoursContact[0] = "<b>Hours of Operation</b>";
		hoursContact[1] = "Mon-Thu: 	9:00AM � 6:00PM";
		hoursContact[2] = "Fri: 	9:00AM � " + closingTime;
		hoursContact[3] = holidayschedule;
		
		contactInfo[1] = brazilPhone;
		contactInfo[2] = usPhone;
		contactInfo[3] = hoursContact;
		
	break;
	case "foreign":
	
		$("#formHolder").remove();
		showform = false;
	
		contactInfo["title"] = "International Department"/*B&H Phone Numbers For International Customers*/;
		
		foreignPhone = new Array ()
		foreignPhone[0] = "<b>B&H Phone Numbers For International Customers</b>";
		foreignPhone[1] = "Brazil 	0800.891.5877";
		foreignPhone[2] = "Argentina 	0800.333.0326";
		foreignPhone[3] = "Mexico 	001.866.806.9070";
		foreignPhone[4] = "Uruguay 	000-416-203-7505";
		foreignPhone[5] = "Venezuela 	0800.100.2714";
		foreignPhone[6] = "U.K. 	0808.234.7276";
		foreignPhone[7] = "India 	020.30521900";
		
		foreignFax = new Array ()
		foreignFax[0] = "<b>Fax numbers</b>";
		foreignFax[1] = "Brazil Fax 	0800.891.0320";
		foreignFax[2] = "India Fax 	    1.800.22.8008";
		foreignFax[3] = "All others 	212.239.7742";
		foreignFax[4] = "<P><a href='/find/HelpCenter/int-shippingRulesPolicies.jsp#shippingPolicies'>See our International Policy page</a></P>";
		
		contactInfo[1] = foreignPhone;
		contactInfo[2] = foreignFax;

	break;
	case "spanish":
		contactInfo["title"] = "Spanish Department";
		
		
		spContact = new Array ()
		/*spContact[0] = "<b>By Phone</b>";
		spContact[1] = "Phone: 	800.947.8003 or 212-239-7503";
		spContact[2] = "<br/>Fax: 	<br/> Price Request: 800.743.0895 or 212.239.7509 <br/> PO's: 800.851.5292 or 212.239.7759";*/
		
		contactInfo[1] = spContact;
		
	break;
	case "surveillance":
		contactInfo["title"] = "Surveillance Video Inquiries";
		
		
		surveillanceContact = new Array ()
		/*spContact[0] = "<b>By Phone</b>";
		spContact[1] = "Phone: 	800.947.8003 or 212-239-7503";
		spContact[2] = "<br/>Fax: 	<br/> Price Request: 800.743.0895 or 212.239.7509 <br/> PO's: 800.851.5292 or 212.239.7759";*/
		
		contactInfo[1] = surveillanceContact;
		
	break
	
	case "stagelighting":
		contactInfo["title"] = "Stage and Theatrical Lighting Inquiries";
		
		
		stageLightingContact = new Array ()
		/*spContact[0] = "<b>By Phone</b>";
		spContact[1] = "Phone: 	800.947.8003 or 212-239-7503";
		spContact[2] = "<br/>Fax: 	<br/> Price Request: 800.743.0895 or 212.239.7509 <br/> PO's: 800.851.5292 or 212.239.7759";*/
		
		contactInfo[1] = stageLightingContact;
		
	break
	case "sportoptics":
		contactInfo["title"] = "Binoculars and Scopes Inquiries";
		
		
		sportopticsContact = new Array ()
		/*spContact[0] = "<b>By Phone</b>";
		spContact[1] = "Phone: 	800.947.8003 or 212-239-7503";
		spContact[2] = "<br/>Fax: 	<br/> Price Request: 800.743.0895 or 212.239.7509 <br/> PO's: 800.851.5292 or 212.239.7759";*/
		
		contactInfo[1] = sportopticsContact;
		
	break
	
	case "webmaster":
		
		/*
		contactInfo["title"] = "Web Site Comments Department";
		
		webEmail = new Array ()
		webEmail["title"] = "Web Site Comments";
		webEmail[0] = "Email B&H Webmaster";
		
		contactInfo[2] = webEmail;
		*/
		
	break;
	default:
	
		contactInfo["title"] = "B&H";
		
		bhAddress = new Array ()
		bhAddress["title"] = "Mailing Address";
		bhAddress[0] = "B&H Photo Video";
		bhAddress[1] = "420 9th Avenue";
		bhAddress[2] = "New York, N.Y. 10001";
		
		contactInfo[2] = bhAddress;
		
	}
	
	// if there is nothing in the array, dont display anything
	if(!contactInfo.length) {
		$("#fullContactHolder").css({display:"none"});
	} else {
		
		// loop through the arrays and output to the document
		for (x in contactInfo)
		{

			if(x != "title") {
				
				// append a new contact info block
				$("#fullContactHolder").append("<div  class='indContactHolder' id =indContactHolder_"+x+">");
				
				//loop through the sub arrays
				for (i in contactInfo[x])
				{
					// add element and value 
					$("#indContactHolder_"+x).append("<div id=contactInfo_"+x+"_"+i+">"+contactInfo[x][i]+"</div>");
					// if it is a title then give it the bold class
					if (i == "title") {
						$("#contactInfo_"+x+"_"+i).addClass("bold");
					}
				}
				$("#fullContactHolder").append("</div>");
				
			} else {
				// if it is a root level title
				$(".deptName").html(contactInfo[x]);
			}
				
		}
		
		$("#fullContactHolder").css({display:"block"});
	
	}
	
	$("#fullContactHolder").append("<div class='clearBoth'></div>");
	
	// check to see if email form has been removed and if not, then display it
	if(showform != false) {
		$("#formHolder").css({display:"block"});
	}
	
};
