// JavaScript Document
var frameNo=1;
var hig = $(window).height();
var wid = $(window).width();
var margin_top=hig-180;
var $move_by=1280;
var $frame_left=0;
var $frame_no=1;
var timer;
var maxCount;
var totalWidth;
function init(){


var $new_frame_no = (($frame_no/1) + 1);
var $new_left = (($frame_left/1) + $move_by);
var $new_frame_atrr = $new_left;


if( $new_frame_no <= maxCount){
$(".scroll_body").animate({left: -$new_frame_atrr+"px"}, 1000);
  $frame_left=$new_left;
  $frame_no=$new_frame_no;
  
}

if($new_frame_no==maxCount){
	
	clearInterval(timer);
	}
setTimeout("contentChange()", 1000);
	}



	
	
	
	
//Innter Tabs-----------------------------------------------------------------------------

function showContent(a)	{


var totLength=$(".tabContent").length;

//alert(totLength);
		
	var a;
	for(i=1; i<=totLength; i++)
		{
			if(i!=a){
			document.getElementById('cont' + i).style.display='none';
			document.getElementById('tab' + i).className=''
			}
		
		}
		document.getElementById('cont' + a).style.display='block';
		document.getElementById('tab' + a).className='selected'
	}
	
	

function casestudies(a)	{

	var a;
	for(i=1; i<=4; i++)
			{
			document.getElementById('case' + i).style.display='none';
			document.getElementById('tabs' + i).className=''
			}
		document.getElementById('case' + a).style.display='block';
		document.getElementById('tabs' + a).className='selected'
	}	
	
	
	
	
function toggle(n){
	
	for(var i=1; i<=2; i++){
	
	if(i!=n){
		
		$('#openTab'+i).slideUp('medium');
		$('#case'+i).removeClass('downA');
		}
	}

$('#getInTouch').slideUp('medium');
$('#openTab'+n).slideToggle('medium');
$('#case'+n).toggleClass('downA');
	
	}
	
function getTouch(){
	
$('#getInTouch').slideToggle('medium');
$('#getIn').toggleClass('downWA');

for(var i=0; i<=2; i++){
	$('#openTab'+i).slideUp('medium');
	
	}
	}

	
	
function showTabs()
{
	
//	alert('ddd');
	if(document.URL.toString().indexOf('=') != "-1")
	{
			//document.getElementById('menu_main').style.display = 'none';

       	var Par= document.URL.toString().substr(document.URL.toString().indexOf('=') + 1);
		//alert(document.URL.toString().indexOf('='));
		
		
		if(Par=="compAnalyis" || Par=="visualDesign" || Par=="microsoft" || Par=="marketing")
		{
			showContent('1');
			
		}		
		if(Par=="indAnalyis" || Par=="userInterface" || Par=="opensource" || Par=="search")
		{
			showContent('2');
			
		}		
		if(Par=="roiAnalyis" || Par=="usabilityStudy" || Par=="j2ee"  || Par=="socialMediaMkt")
		{
			showContent('3');
			
		}		
		if(Par=="brandStrategy" || Par=="creativeStoryboards" || Par=="mobileApplication"  || Par=="emailMarketing")
		{
			showContent('4');
			
		}		
		if(Par=="infoArchitecture" || Par=="brandIdentity" || Par=="viral"  || Par=="socialMedia")
		{
			showContent('5');
			
		}		
		if(Par=="protoWireframe" || Par=="contentDevelopment" || Par=="richMedia" || Par=="analytics"  )
		{
			showContent('6');
			
		}		
		
		
				
	}
}
	
	

var autono=1;
var cnt;
var vartime;
var flag=0;
var websiteimg;
var linkname;
var webimgid;
function selectwebsiteimg(no)
{//alert(webimgid);
//alert(websiteimg);

	//websiteimg = document.getElementById("websiteimg");
	$('.borderimg').fadeOut("fast");
	websiteimg.src= '../../portfolioimages/'+webimgid +'0'+ no +'.jpg';
	/*websiteimg.alt= '../../portfolioimages/'+webimgid +'0'+ no;
	alert(websiteimg.alt);*/
	$('.borderimg').fadeIn("slow");
	
	
	//alert(cnt);
	for(i=1;i<=cnt;i++)
	{
	
		document.getElementById(linkname + i).className='desel';
	}//alert('dd');
	document.getElementById(linkname + no).className='sel';
	removePreload();
	
	
}
function showwebsite_pge(no)
{//alert(no + 'ddd' + autono)
	if(flag==1)
	{
		if(autono<=cnt)
		{//alert(autono+'sss');
			selectwebsiteimg(autono);
			vartime = setTimeout("showwebsite_pge("+ autono +")",6000);
			autono++;
		}else
		{//alert(autono)
			if(autono>cnt)
			{
				autono=1;
				selectwebsiteimg(autono);
				vartime = setTimeout("showwebsite_pge("+ autono +")",6000);
				autono++;
			}
		}
	}
	else
	if(flag==0)
	{//alert('dddd');
		clearTimeout(vartime);
		selectwebsiteimg(no);
		autono=no+1;
		//alert('dddd');
		flag=1;
		vartime = setTimeout("showwebsite_pge("+ autono +")",8000);
	}
}
function autoslide(tno,linkid,imgid)
{	

webimgid=imgid;

	//alert(tno+' '+linkid+'  '+imgid);
	websiteimg=document.getElementById(imgid);
	//alert(document.getElementById(imgid));
	linkname=linkid;
	cnt=tno;
	autono++;
	flag=1;
	vartime = setTimeout("showwebsite_pge("+ autono +")",6000);
	//alert(linkname);
	//showwebsite_pge(no);
	
}
function showwebsite_pgaeto(no,linkid,imgid)
{
	//$('#loading').css({"display":"block"}).animate({opacity:1},1000);
	webimgid=imgid;
	websiteimg=document.getElementById(imgid);
	linkname=linkid;
	flag=0;
	showwebsite_pge(no);
	//myimg.src= '../../portfolioimages/'+webimgid +'0'+ no +'.jpg';
	//alert(myimg.src);
//url = $('.borderimg').css({"display":"block", "visibility":"visible"}).html();			//get the image url from the div block
//loaded=false;
//alert(url.search(/<.*/));
									//check whether image has been loaded
		//if(url.search(/<.*/) != -1){
		//	loaded=true;
			//tmp[i] = $('#myImg').children();
			//tmp[i].onload=function(){
			//$('#loading').css({"display":"block"});
			//}
			//}
			
//$('#loading').css({"display":"block"});
//$('#category'+no+ 'img').load(function(){
//$('#loading').css({"display":"none"});
			
     
}

function removePreload(){
	
	$('#loading').remove();
	}

function showcategory(no,catcnt,indcnt,linkid,imgid)
{	//alert(indcnt);
	clearTimeout(vartime);
	for(i=1;i<=catcnt;i++)
	{
		document.getElementById('category' + i).style.display='none';
		document.getElementById('categorylink' + i).className='';
	}
	//alert('ddd');rightsel
	document.getElementById('category' + no).style.display='block';
	document.getElementById('categorylink' + no).className='rightsel';
	
	webimgid=imgid;
	linkname=linkid;
	autono=1;
	//alert(autono +"ccc"+indcnt);
	autoslide(indcnt,linkname,webimgid);
}


function selectIndex(){
	
	var index  = document.getElementById('selectList').value;
	//document.getElementById('txtChange').value=Vcat;
	document.form1.txtChange.value=index;
}
	
function changeCountry(){
	
	var index  = document.getElementById('selectCountry').value;
	
	arrCountry = index.split('~');
	//document.getElementById('txtCountry').value=Vcat;
	document.form1.txtCountry.value=arrCountry[0];
	document.form1.countrycode.value=arrCountry[1];
	
}

function selectYear(){
	//alert(document.getElementById('selYear').value+'---'+document.getElementById('selMonth').value);
	
	var index  = document.getElementById('selYear').value;
	
	var yr = document.getElementById('selYear').value;
	var mn = document.getElementById('selMonth').value;
	
	if(yr>=0 && mn >= 0){	
	var res = '';
	if(yr != 'Year' && mn!='Month'){	
	res = yr+'.'+mn
	document.getElementById('txtExp').value=res;
	}	
	else if(document.getElementById('txtExp').value=='')
	document.getElementById('txtExp').value=index;
	}
	else if(yr>=0 && mn == 'Month'){
	document.getElementById('txtExp').value=yr;
	}
	else if(yr == 'Year'){
	document.getElementById('txtExp').value='0.'+mn;
	}
	
	if(document.getElementById('selYear').value == 'Year' && document.getElementById('selMonth').value=='Month')
	document.getElementById('txtExp').value='';
	
	if(document.getElementById('selYear').value == 'Year' && document.getElementById('selMonth').value=='0')
	document.getElementById('txtExp').value='';
	else if(document.getElementById('selYear').value == '0' && document.getElementById('selMonth').value=='Month')
	document.getElementById('txtExp').value='';
	
	document.form1.txtYear.value=index;
}

function selectMonth(){
	//alert(document.getElementById('selYear').value+'---'+document.getElementById('selMonth').value);
	
	var index  = document.getElementById('selMonth').value;
	
	var yr = document.getElementById('selYear').value;
	var mn = document.getElementById('selMonth').value;
	
	if(yr>=0 && mn >= 0){	
	var res = '';
	if(yr != 'Year' && mn!='Month')	{
	res = yr+'.'+mn
	document.getElementById('txtExp').value=res;
	}
	else if(document.getElementById('txtExp').value=='')
	document.getElementById('txtExp').value=index;
	}
	else if(yr=='Year' && mn >= 0){
	document.getElementById('txtExp').value='0.'+mn;
	}
	else if(mn == 'Month'){
	document.getElementById('txtExp').value=yr;
	}

	
	if(document.getElementById('selYear').value == 'Year' && document.getElementById('selMonth').value=='Month')
	document.getElementById('txtExp').value='';
	
	if(document.getElementById('selYear').value == '0' && document.getElementById('selMonth').value=='Month')
	document.getElementById('txtExp').value='';
	else if(document.getElementById('selYear').value == 'Year' && document.getElementById('selMonth').value=='0')
	document.getElementById('txtExp').value='';
	
	
	document.form1.txtMonth.value=index;
}

function changeCountrybuzz(){
	
	var index  = document.getElementById('selectCountry').value;
	
	arrCountry = index.split('~');
	//document.getElementById('txtCountry').value=Vcat;
	document.business_enquiry_form.txtCountry.value=arrCountry[0];
	document.business_enquiry_form.countrycode.value=arrCountry[1];
	
}	

	
function showOverView(a)	
	{
	var a;
	
	for(i=1; i<=4; i++)
		{
			if(i!=a){
			document.getElementById('cont' + i).style.display='none';
			document.getElementById('head' + i).style.display='block';
			}
		
		}
		document.getElementById('cont' + a).style.display='block';
		document.getElementById('head' + a).style.display='none';
		document.getElementById('changeImg' + a).className='bgImg'+a;
	}
	
	
function currentOpenings(a) {
		var totC = document.getElementById('totCareer').value;
		for(i=1; i<=totC; i++){
			if(i!=a){
			$('#current'+i).slideUp('medium');
			document.getElementById("heading" + i).className='collapse';
			}
			}	
		//alert(a);
		//document.getElementById('current' + a).style.display='block';
		$('#current'+a).slideToggle('medium');
		$('#heading'+a).toggleClass('expand');
		//document.getElementById("heading" + a).className='expand';
		
	}



/*Tool Tip Stores*/
$(document).ready(function() {  
$('img[name=tooltipstores]').mouseover(function(e) {  
var tip = $(this).attr('title');      
$(this).attr('title','');  
$("#cntbdy").append('<div id="tooltip" style="width:100px; z-index:900000;"><div class="tipHeader"></div><div class="tipBody" style="width:90px;">' + tip + '</div><div class="tipFooter"></div></div>');       
$('#tooltip').css('top', e.pageY - 60 );  
$('#tooltip').css('left', e.pageX - 50 );  
$('#tooltip').fadeIn('1000');  
//$('#tooltip').fadeTo('10',0.8);  
}).mousemove(function(e) { 
$('#tooltip').css('top', e.pageY  - 60 );  
$('#tooltip').css('left', e.pageX - 50 );  
}).mouseout(function() {  
$(this).attr('title',$('.tipBody').html());  
$("#cntbdy").children('div#tooltip').remove();  
});  
});


function portfolioPage(){
if(document.URL.toString().indexOf('=') != "-1")
	{	
		var Par= document.URL.toString().substr(document.URL.toString().indexOf('=') + 1);
		
		if(Par=="hsbcmicrosite")
		{
			showcategory(5,5,2,'hsbcclimatenav','hsbcclimate');
		}
		else if(Par=="raise")
		{
			showcategory(5,5,4,'hsbcclimatenav','hsbcclimate');
		}
		else if(Par=="ssomicrosite")
		{
			showcategory(2,2,2,'webnav','websitess');
		}
		
	}

	}
	
$(function(){
/*$("#social").click(function(){
  $(".socialLinks").css({'display': 'block'});
  //$(".socialLinks").animate({"left": "250px"}, "7000");
});*/
$("#social").hover(
  function () {
    //$(".socialLinks").css({'display': 'block'});
	 $(".socialLinks").fadeIn("slow");
  },
  function () {
     $(".socialLinks").fadeOut("slow");
  }
);

$(".socialLinks").hover(
  function () {
    //$(".socialLinks").css({'display': 'block'});
  },
  function () {
	 $(".socialLinks").fadeOut("fast");
    //$(".socialLinks").css({'display': 'none'});
  }
);
});


