﻿// JavaScript Document
ind_c = 0;

pic_id = new Array("pic_together","pic_ipad","pic_video");
a_id = new Array("gallery-together","gallery-ipad","gallery-video");

news_index=0;

cicle_num = 0;

var t;

/*get key word focus*/
function trim(stringToTrim) {
				var trm =  stringToTrim.split(' ').join('');
				 return trm.toLowerCase();
				//return stringToTrim.replace(/^\s+|\s+$/g,"");
		}		
		
		
function GetQueryString(name) 
{ 
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
var r = document.referrer.substr(1).match(reg); //window.location.search.substr(1).match(reg); 
if (r!=null) return unescape(r[2]); return null; 
} 

function getkeywords() {
		
		var x = document.referrer;		
			if(x == ""|| x=="null"){
						return x;
				}
				else{					
					var strReplace = "+";
					x = x.replace(strReplace," ");
					x = trim(x);
					return x; 
				}
		}
		
function CompareSearchKey()	{
			
			//var keyVal = getkeywords();
			//keyVal = keyVal.toLowerCase();
			//keyVal =new RegExp(keyVal, "i");
			
			keyVal=""
			keyVal = getkeywords();
			if (keyVal==null) keyVal="";

			
var imgExist;

var imgArr = new Array("image1","image2","image3");

//web meeting
var image1 = new Array("Webconferencing","Online-Meeting","Web-Meeting","DesktopSharing","sharedesktop","FileSharing","ApplicationSharing","webexmeeting","webexmeetingcenter");

//mobile
var image2 = new Array("webexmobile","webexformobile","webexandmobiles","wEbex for moBiLe","webexmobile","webexiphone","webexipad","webexsmartphones","mobilevideoconferencing","mobileremotedesktopsoftware");

//video
var image3 = new Array("Videoconferencing","Videoconference","webex video","Video webex","highqualityvideo","WebcamVideo","highqualityvideo","highqualityvideoconferencing","highquality","highqualityvideoconferencing","highqualityvideoconferencing","webexhighqualityvideoconferencing","webexhqvideoconferencing","webexmeetingcenterhighquality");

//training
//var image5 = new Array("webex for elearning","elearning with webex","webex elearning","web ex elearning","webx elearning","webex e-learning","try webex elearning","webex elearning trial","elearning software","education video conferencing","educational video conferencing","educational videoconferencing","education webcast","e learning","elearning provider","e learning software","elearning software","elearning software companies","software for e learning","software for elearning","free elearning software","download elearning software","elearning software trial","easy elearning software","effective elearning software","elearning software demonstration","affordable elearning software","interactive online training","online learning training","online training companies","online training system","web based training","web based training company","video conferencing for learning","video conferencing in education","best web based training","web based training development","web based training system");

if(keyVal!="") {
	for(i=0;i<imgArr.length;i++){
		var imgArrName = imgArr[i];
		switch(imgArrName){
		case "image1":
			if(image1.toString().replace(/ /g,'').search(keyVal)!=-1){
			imgExist=0;
			}
			break;
		case "image2":
			if(image2.toString().replace(/ /g,'').search(keyVal)!=-1){
			imgExist=1;
			}
			break;
		case "image3":
			if(image3.toString().replace(/ /g,'').search(keyVal)!=-1){
			imgExist=2;
			}
			break;
			default : '';
		}
	}
}

if(imgExist){
	return imgExist;
}else{
	return 0;
}			
			
}


/*end key word*/


function slideSwitch() {

	ind_n = ind_c + 1;
	if (ind_n == 3) ind_n = 0;
	
	$("#"+pic_id[ind_c]).fadeOut(500);
	$("#"+pic_id[ind_n]).fadeIn(500);
	$("#"+a_id[ind_c]).removeClass("gallery-current");
	$("#"+a_id[ind_n]).addClass("gallery-current");
	
	ind_c = ind_c + 1;
	if (ind_c == 3) ind_c = 0;
	
	cicle_num = cicle_num +1;
	if (cicle_num == 3){
		if (t)		clearInterval(t);
	}

}

function newSwitch() {
		clearInterval(n);
		$("#news-ticker .news").eq(news_index).hide();
		if(news_index == 2){news_index=0;}
		else {news_index = news_index+1;}
		$("#news-ticker .news").eq(news_index).show();
		n=setInterval( "newSwitch()", 5000 );
}

var n;
$(function() {
	//$("#slideshow span").css({"opacity":"0.7","display":"block"});

	$("#slideshow").append("<div id='tray'><table border='0' cellpadding='0' cellspacing='0' height='33' id='tb-tray' width='450'><tr><td align='left' width='150'><a href='javascript:void(0);' id='gallery-together'><span class='gallery-text'>WebEx Meetings </span></a></td><td align='left' width='150'><a href='javascript:void(0);' id='gallery-ipad'><span class='gallery-text'>WebEx for iPad </span></a></td><td align='left' width='150'><a href='javascript:void(0);' id='gallery-video'><span class='gallery-text'>High-Definition Video</span></a></td></tr></table></div><div id='pic_together'><span class='meetings current'><H1 class='hero-title'>Meet with anyone, anywhere</H1><p class='hero-subtitle' align='left'>Get more done, faster,<br>online with WebEx.</p><p align='left' class='hero-subtitle'>Just <span class='f36'>£30</span> /month</p><table align='left' border='0' cellpadding='0' cellspacing='0' width='320'><tr><td width='140' align='left'><table border='0' cellpadding='0' cellspacing='0' width='122'><tr><td width='122'><a class='cta-buy'  id='Together_Buy' href='http://www.webex.co.uk/go/uk_buy_mc'>Buy Now</a></td></tr></table></td><td width='180' align='left'><table border='0' cellpadding='0' cellspacing='0' width='142'><tr><td width='142'><a class='cta-ft' href='http://www.webex.co.uk/go/uk_webex_ft' id='Together_FT'>Try It Free</a></td></tr></table></td></tr></table><p align='left' class='hero-learnmore'><br>Or <a href='/overview/index.html'>learn more</a> about WebEx online meetings</p></span></div><div id='pic_ipad'><span class='ipad'><H1 class='hero-title'>Join WebEx meetings on your Apple iPad</H1><p class='hero-subtitle' align='left'>Make sure WebEx is easily accessible—wherever you are—with our free application.</p><table align='left' border='0' cellpadding='0' cellspacing='0' width='320'><tr><td width='140' align='left'><table align='left' border='0' cellpadding='0' cellspacing='0' width='122'><tr><td width='122'><a class='cta-buy' href='/overview/mobile-meetings.html'  id='Ipad_LearnMore'>Learn more</a></td></tr></table></td><td width='180' align='left'><table border='0' cellpadding='0' cellspacing='0' width='142'><tr><td width='142'><a class='cta-ft2' id='Ipad_FT' href='http://www.webex.co.uk/go/uk_webex_ft'>Try WebEx Free</a></td></tr></table></td></tr></table></span></div><div id='pic_video'><span class='video'><H1 class='hero-title'>Bring meetings to life with WebEx high-definition video</H1><p align='left' class='hero-subtitle'>Create a true  meeting experience <br/>with high-definition video.</p><p align='left' class='hero-subtitle'>Just <span class='f36'>£30</span> /month</p><table align='left' border='0' cellpadding='0' cellspacing='0' width='320'><tr><td width='140' align='left'><table border='0' cellpadding='0' cellspacing='0' width='122'><tr><td width='122'><a class='cta-buy' href='http://www.webex.co.uk/go/uk_buy_mc' id='Video_Buy'>Buy Now</a></td></tr></table></td><td width='180' align='left'><table border='0' cellpadding='0' cellspacing='0' width='142'><tr><td width='142'><a class='cta-ft' id='Video_FT1' href='http://www.webex.co.uk/go/uk_webex_ft'>Try It Free</a></td></tr></table></td></tr></table><p class='hero-learnmore' align='left'><br />Or <a href='/overview/video-conferencing.html'>learn more</a> about WebEx high-definition video</p></span></div>");
	
	//$(".current").css("opacity","1.0");

	
	$("#news-ticker .news:first").show();
	

	
	keynum=CompareSearchKey(); 
	switch(keynum)
	{
		
		case 0:
				ind_c = 0;
				break;

		case 1:
				ind_c = 1;
				break;
		case 2:
				ind_c = 2;
				break;
		default:
				ind_c = 0;
				break;
	}
	

	$("#"+pic_id[ind_c]).fadeIn();
	$("#"+a_id[ind_c]).addClass("gallery-current");

	
	var b_v = navigator.appVersion;
	var IE6 = b_v.search(/MSIE 6/i) != -1;

	if (IE6)
	{
		DD_belatedPNG.fix('img, #tray, #news-ticker, #left-arrow, #right-arrow, #pod1, #pod2, #pod3');  
	} 
	
	
    n=setInterval( "newSwitch()", 5000 );	
    t=setInterval( "slideSwitch()", 5000 );
	
	

	$("#gallery-together").click( function() {
		if (t)		clearInterval(t);
		if (ind_c != 0){
			$("#"+pic_id[ind_c]).fadeOut(500);
			$("#"+pic_id[0]).fadeIn(500);
			$("#"+a_id[ind_c]).removeClass("gallery-current");
			$("#"+a_id[0]).addClass("gallery-current");
		}
		ind_c = 0;
		track_clicks('wx:uk:hero:together:thumbnail_click','slideshow');


	});
	
			
	$("#gallery-ipad").click( function() {
		if (t)		clearInterval(t);
		if (ind_c != 1){
			$("#"+pic_id[ind_c]).fadeOut(500);
			$("#"+pic_id[1]).fadeIn(500);
			$("#"+a_id[ind_c]).removeClass("gallery-current");
			$("#"+a_id[1]).addClass("gallery-current");
		}
		ind_c = 1;
		track_clicks('wx:uk:hero:ipad:thumbnail_click','slideshow');

	});
		
	$("#gallery-video").click( function() {
		if (t)		clearInterval(t);
		if (ind_c != 2){
			$("#"+pic_id[ind_c]).fadeOut(500);
			$("#"+pic_id[2]).fadeIn(500);
			$("#"+a_id[ind_c]).removeClass("gallery-current");
			$("#"+a_id[2]).addClass("gallery-current");
		}
		ind_c = 2;
		track_clicks('wx:uk:hero:hq-video:thumbnail_click','slideshow');

	});
	
	$("#left-arrow").click( function(event) {
		event.preventDefault();
		$("#news-ticker .news").eq(news_index).hide();
		if(news_index == 0){news_index=2;}
		else {news_index = news_index-1;}
		$("#news-ticker .news").eq(news_index).show();
	});
	
	$("#right-arrow").click( function(event) {
		event.preventDefault();
		$("#news-ticker .news").eq(news_index).hide();
		if(news_index == 2){news_index=0;}
		else {news_index = news_index+1;}
		$("#news-ticker .news").eq(news_index).show();
	});
	
});


$("#Together_Buy").click( function() {
		track_clicks('wx:uk:hero:together:buy_now','slideshow');
});
$("#Together_FT").click( function() {
		track_clicks('wx:uk:hero:together:try_it_free','slideshow');
});
$("#Ipad_LearnMore").click( function() {
		track_clicks('wx:uk:hero:ipad:learn_more','slideshow');
});
$("#Ipad_FT").click( function() {
		learnmore_click("Ipad_FT");
		track_clicks('wx:uk:hero:ipad:try_webex_free','slideshow');
});
$("#Video_Buy").click( function() {
		track_clicks('wx:uk:hero:hq-video:buy_now','slideshow');

});
$("#Video_LearnMore").click( function() {
		track_clicks('wx:uk:hero:hq-video:learn_more','slideshow');
});

// function track custom clicks to site catalyst.
/*
* link_name => link name of custom link; will be shown in site catalyst  reporting
* linkcategory => category to determine which eVars/eProps to store
*  choices: slideshow
*/
function track_clicks(link_name, linkcategory){
	var LinkName = 'undefined';
				   
	if(typeof link_name != 'undefined')
	{
		LinkName= link_name;
	}
				   
	if(typeof linkcategory != 'undefined')
	{
		switch(linkcategory){
			case 'slideshow':
			s.linkTrackVars="prop30,eVar30";
			s.eVar30 = link_name;
			s.prop30 = link_name;  
			break;
			default:       
		}
	}
	//s.sa('webextest');
	void s.tl(this, 'o', LinkName);
}


