$jqry=jQuery;
var timeoutID;

DD_roundies.addRule('.v_content,#timvandamme,#ad_banner','5px', true);
DD_roundies.addRule('#page-wrap #slider-stopper','3px', true);
DD_roundies.addRule('.subs_box,.news_box,.ads_box', '5px', true);
DD_roundies.addRule('.contact_content', '5px 0 5px 5px', true);
DD_roundies.addRule('.contact_navigation', '5px 5px 0 0', true);
DD_roundies.addRule('#language_selection,.just_round,.train_box', '5px', true);
DD_roundies.addRule('#bottom_navigation', '0 0 5px 5px', true);
DD_roundies.addRule('.menu0 li.hover', '5px 5px 0 0', true);
DD_roundies.addRule('#main0', '0 0px 5px 5px', true);
DD_roundies.addRule('#tabs0,.path', '5px 5px 0 0', true);
DD_roundies.addRule('.menu0 li', '5px 5px 0 0', true);
DD_roundies.addRule('.word_link,#products_list_end', '5px', true);
DD_roundies.addRule('#newsitem_pubdate,.contact_content .thumbNav li .panel1', '5px 0 0 5px', true);
DD_roundies.addRule('#page-wrap #slider', '5px', true);
DD_roundies.addRule('.mav_paging a', '3px', true);
DD_roundies.addRule('.scroll,.anythingWindow', '0px 5px 5px 5px', true);
DD_roundies.addRule('.contact_content .thumbNav li .panel2', '0px 5px 5px 0px', true);

//DD_roundies.addRule('#mav_page_fragment_4 input', '10px', true);
DD_roundies.addRule("#container","8px",true);
//DD_roundies.addRule("#simpleTooltip","8px",true);
DD_roundies.addRule(".news_content_2","5px",true);
//DD_roundies.addRule("","0px 5px 5px 0px",true);

$jqry(document).ready(function(){
	$jqry('#portal_sub_title_3 a,.little-card,#careers_tab_gz a').corner('right 5px');
	$jqry('#portal_sub_title_1 a,#careers_tab_hk a').corner('left 5px');
	$jqry('#newsitem_topic h3').corner('top 10px');
	$jqry('#newsitem_text').corner('bottom 10px');
	$jqry('.call_email,.External_resources,.pg_resources #document_listing_results .item_record_border').corner('5px');
	$jqry('#pg_contact-us .contact_content .titleList a,.life_left_meun a').corner('5px');
	
	if($jqry('#newsitem').size()>0){$jqry('#mav_page_fragment_3').css("width","980px");}
	clearTimeout(timeoutID);
	timeoutID = setTimeout(function() {
		//alert($jqry('.thumbNav li a').size());
		$jqry('.pg_home .thumbNav li a,.pg_our-philosophy .thumbNav li a').corner("top 5px");
		$jqry('.boxgrid').corner("5px");
		
//		if($jqry("#pg_news .item_body .abstract").size()>0){
//			target = $jqry("#pg_news #news_eBusiness .item_body > a,#pg_news #news_business_tips .item_body > a,#pg_news #news_marketing_tips .item_body > a");
//			$jqry(target).prepend('<img src="/mavista/img/public/quote.png" style="position: absolute;">');
//		}
		if(!("\v"=="v")){
			//$jqry('#pg_news #news_listing_results li,#pg_news .item_thumbnail_photo img').corner("5px");
		}
	},500);
	//$jqry('.thumbNav li a').corner( , 
});



$jqry(function(){
	$jqry('#mav_menu li a').corner('5px');
	$jqry('#mav_menu li a')
		.css( {backgroundPosition: "-20px 35px"} )
		.mouseover(function(){
			$jqry(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500});
		})
		.mouseout(function(){
			$jqry(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
				$jqry(this).css({backgroundPosition: "-20px 35px"});
			}});
		});
});



//Set up Sliders
//**************
$jqry(function() {

	$jqry('#philosophySlider')
			.anythingSlider(
					{
						startStopped : true, // If autoPlay is on, this can
												// force it to start stopped
						width : 980, // Override the default CSS width
						height : 350,
						theme : 'default',
						autoPlayLocked : false, // If true, user changing slides
												// will not stop the slideshow
						resumeDelay : 10000, // Resume slideshow after user
												// interaction, only if
												// autoplayLocked is true (in
												// milliseconds).
						onSlideComplete : function(slider) {
							// alert('Welcome to Slide #' + slider.currentPage);
						},
						navigationFormatter : function(index, philosophy) { // Format
																			// navigation
																			// labels
																			// with
																			// text
							return [ 'Our Philosophy', 'Our Culture',
									'Our Clients' ][index - 1];
						}

					});
	// ******************************
	$jqry('#portfoliosSlider')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 920, // Override the default CSS width
				height : 300,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				}

			});
	// ******************************
	
	
	$jqry('#template_slide')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 620, // Override the default CSS width
				height : 560,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				}

			});
	// ******************************
	
	$jqry('#contact_us_tab')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 930, // Override the default CSS width
				height : 420,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				},
				navigationFormatter : function(index, contact_us_tab) { // Format
																	// navigation
																	// labels
																	// with
																	// text
					return [ 'Hong Kong', 'Guangzhou'][index - 1];
				}

			});
	
	
	$jqry('.mavista_tabs')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 615, // Override the default CSS width
				height : 1000,
				theme : 'default',
				resizeContents : false,
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					$jqry("#mav_content_inner_fragment_1").css("height","");
				},
				navigationFormatter : function(index, contact_us_tab) { // Format
																	// navigation
																	// labels
																	// with
																	// text
					return [ '<img src="/mavista/upload/Image/mavista/basic.png">', 
					         '<img src="/mavista/upload/Image/mavista/mobile.png">', 
					         '<img src="/mavista/upload/Image/mavista/soho.png">',
					         '<img src="/mavista/upload/Image/mavista/enterprise.png">', 
					         '<img src="/mavista/upload/Image/mavista/eshop.png">'][index - 1];
				}

			});
	
	
	
	
	$jqry('.careers_tab')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 930, // Override the default CSS width
				height : 1050,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				},
				navigationFormatter : function(index, careers_tab) { // Format
																	// navigation
																	// labels
																	// with
																	// text
					return [ 'Vacancies - Hong Kong Office', 'Vacancies - Guangzhou Office'][index - 1];
				}

			});
	// ******************************
	
	
	$jqry('.clients-logoSlider')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 535, // Override the default CSS width
				height : 40,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				}

			});
	$jqry(".philosophy3 .anythingSlider .thumbNav").remove();
	// ******************************
	$jqry('#new_projects #news_listing_results ul')
	.anythingSlider(
			{
				startStopped : false, // If autoPlay is on, this can
										// force it to start stopped
				width : 220, // Override the default CSS width//290
				height : 200,//140
				theme : 'default',
				autoPlayLocked : true, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 80000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				}

			});
	
	$jqry("#new_projects .thumbNav").remove();
	
	// ******************************
	$jqry('#home_content1_banner')
	.anythingSlider(
			{
				startStopped : true, // If autoPlay is on, this can
										// force it to start stopped
				width : 525, // Override the default CSS width
				height : 300,
				theme : 'default',
				autoPlayLocked : false, // If true, user changing slides
										// will not stop the slideshow
				resumeDelay : 10000, // Resume slideshow after user
										// interaction, only if
										// autoplayLocked is true (in
										// milliseconds).
				onSlideComplete : function(slider) {
					// alert('Welcome to Slide #' + slider.currentPage);
				},
				navigationFormatter : function(index, home_content1_title) { // Format
																	// navigation
																	// labels
																	// with
																	// text
					return [ 'Web Design', 'Web Development',
							'Online Marketing', 'Online Shop' ][index - 1];
				}

			});
//******************************
});


// Tips
$jqry(function(){
	$jqry("a.with-tooltip").simpletooltip();
	$jqry("#pg_our-philosophy .clients-logoSlider li img").simpletooltip();
	
});

//Search hide banner
//$jqry(document).ready(function(){
//	if($jqry("#news_search_results_div").size()>0){
//		$jqry("#page-wrap,#twitter").hide();
//		$jqry("#city_bg").show();
//		$jqry("#mav_page_fragment_3").css("width","980px");
//	}
//});


$jqry(function(){
	if($jqry(".pg_portal").size()>0||$jqry(".pg_content_management_features").size()>0||$jqry(".pg_collaboration_and_social_features").size()>0){
		var activedClass = $jqry(".life_left_meun").find(".item_body").get(3);
		$jqry(activedClass).find("a").css("font-weight","bold").css("background-color","#d3d3d3").css("color","#404040");
	}
	if($jqry(".pg_developer").size()>0||$jqry(".pg_portal-administrator-training").size()>0||$jqry(".pg_system_administrator_training").size()>0){
		var activedClass = $jqry(".life_left_meun").find(".item_body").get(4);
		$jqry(activedClass).find("a").css("font-weight","bold").css("background-color","#d3d3d3").css("color","#404040");
	}
	
	if($jqry("#liferay_special_content").size()>0){
		$jqry(".path").css("width","970px").css("margin","-15px 0 0 -20px");
		
	}
	
	if($jqry("#pg_sitemap").size()>0){
		$jqry(".sitemap_level_1 > div > a").each(function() {
			$(this).append("<img src='/mavista/upload/Image/sitemap_circle_1.png'>");
			$(this).find("img").css("position","absolute").css("margin","2px 0 0 5px");
		});
		
		$jqry(".sitemap_level_2").each(function() {
			if($(this).find(".sitemap_level_3").size()<1){
				$(this).css("margin-bottom","25px");
				$(this).find("div").css("min-height","15px").css("margin-bottom","0px");
			}
		});
	}
	
	$jqry(".question").toggle(
		function() {
			$jqry(this).parent().find(".answer").slideDown();
		},
		function() {
			$jqry(this).parent().find(".answer").slideUp();
		}
	);
});

$jqry(function(){
	var target1 = $jqry(".main_product_picture_hot img").get(1);
	$jqry(target1).css("margin-top","-80px");
	var target2 = $jqry(".main_product_picture_hot img").get(2);
	$jqry(target2).css("margin-top","-80px");
	
	if($jqry("#pg_contact-us").size()>0){$jqry("#menu_item_contact-us").attr("class","actived");}
	if($jqry("#pg_news").size()>0){$jqry("#menu_item_news").attr("class","actived");}
	if($jqry("#pg_our-services").size()>0||$jqry(".pg_portal-solutions").size()>0||$jqry(".pg_portal-solutions").size()>0){$jqry("#menu_item_our-services").attr("class","actived");}
	if($jqry("#pg_our-products").size()>0){$jqry("#menu_item_our-products").attr("class","actived");}
	if($jqry("#pg_home").size()>0){$jqry("#menu_item_home").attr("class","actived");}
	
	
	
	
	if($jqry("#pg_our-philosophy").size()>0){
		var sUserAgent = navigator.userAgent.toLowerCase();  
	    var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";    
	    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; 
	    if(bIsIphoneOs||bIsIpad){
	    	$jqry("#pg_our-philosophy .our-philosophy-flash").html("");
	    	$jqry("#pg_our-philosophy .our-philosophy-flash").append("<img src='"+ "/mavista/upload/Image/top_banner/slide_1.png" +"'>");
	    }
	}
	
	
	
	
	$jqry(".template_thum_up").hover(
		function() {
			$jqry(this).animate({opacity:"0"},300);
		},
		function() {
			$jqry(this).animate({opacity:"1"},150);
//			$jqry(this).parent().find(".template_thum_down").fadeOut("150");
		}
	);
	
//	if($jqry(".content_header_background").size()>0){
//		$jqry(".content_header_background").css("height",parseInt($jqry(".content_header").css("height"))+23);
//		
//	}
});



